Monkey compiler bug? (maybe)
Monkey Forums/Monkey Bug Reports/Monkey compiler bug? (maybe)
| ||
This looks like a compiler bug to me: http://www.monkeycoder.co.nz/Community/posts.php?topic=4765#bottom In a quick summary. This code: Function Main() Local a:= New String[1] Local index:Int = 2 a[index - 2] += "Hello!" Print a[0] End Produces this error at compile time: Internal error - decl not semanted Just in case it is not a real bug, maybe a better explanation of what's wrong in the code would be better than the current compiler error message. |
| ||
Apart from the fact that you're calling += on a null array element? |
| ||
Apart from the fact that you're calling += on a null array element? No, I'm not. There are no null strings on Monkey. XD I'm talking about the problem that placing ANY operation inside the index makes the compilation process fail. |
| ||
There are no null strings on Monkey. XD But I want null strings... :( I'm quite sadistic like that. :D Edit: These compile (although the second will fail at runtime): [monkeycode]a[0] += "Hello!" a[index] += "Hello!"[/monkeycode] It seems that using an expression as the index for a String array will break the += operator, but using a constant or a simple variable reference is fine. |
| ||
Yes, it gives the message: "Internal error - decl not semanted " If you ask me, the operator should be able to handle this, but if it's not, a better error message would be welcome. |
| ||
edit: forgive me and disregard my reply, I didn't notice you are creating an array of strings. it's a bug if compiler doesn't throw errors, string[index] should be read only and returns ascii code. |
| ||
I was about to post a bug report, but instead decided to search and found this post. This is definitely a bug that needs to be fixed. It makes what I'm trying to do have extra steps because the compiler apparently can't figure out how to solve math inside an array index call when a += op is used. Broken Function Main:Int() Local arr:String[] = ["hello", "there", "bug", "world"] For Local i:Int = 0 Until 2 arr[i + 2] += arr[i] Next End Working Function Main:Int() Local arr:String[] = ["hello", "there", "bug", "world"] For Local i:Int = 0 Until 2 arr[i] += arr[i + 2] Next End Function Main:Int() Local arr:String[] = ["hello", "there", "bug", "world"] For Local i:Int = 0 Until 2 arr[i + 2] = arr[i] Next End Edit: I am using v64a |
| ||
It does this in version 73b as well. |
| ||
I think this is a related bug. It just popped up when I switched to a newer version from the one I was using. This causes a memory access violation from trans when I try to compile. someObj.location.x += 5 'someObj' was a local var, 'location' was a property to a 2D vector object, and 'x' was a field of that instance. Dunno why, but it doesn't like +=, -=, or really anything with '[op]=' The reason I think it's related is because this works... someObj.location.x = someObj.location.x + 5 When it compiled... C:\Documents\Monkey\76a\bin\transcc_winnt.exe -run -config=debug -target=Html5_Game "C:\Documents\Games\test.monkey" TRANS monkey compiler V1.57 Parsing... Semanting... Monkey Runtime Error : Memory access violation |
| ||
Runnable sample code please?!? This works OK here... Class T Field _x:Int Method X:Int() Property Return _x End Method X:Void( x:Int ) Property _x=x End End Function Main() Local t:=New T t.X+=10 End |
| ||
Here's a broken example I built off of yours.Class Vector2D Field x:Float, y:Float End Class Example Field _location:Vector2D = New Vector2D() Method location:Vector2D() Property Return _location End End Function Main() Local t:=New Example() t.location.x += 2 End Edit: I managed to figure out that this is an implicit conversion problem. If you change the x to an integer, the problem goes away. |
| ||
Hey, could the bug that's causing the problem I talked about above please be fixed. I'm doing the Ludum Dare right now and the compiler keeps crashing with "memory access violation" in all of its vagueness. I finally found a workaround, but this is a serious bug that needs to be resolved. Edit: Okay, so I was wrong, my 'workaround' doesn't work with my code. This had better be fixed 'cause I'm more pissed off than I have been in a long time. I told of this severe bug 5 months ago and you just blew off fixing it and now it's coming back and screwing me over when I'm trying to make a game for a time constrained competition. Edit 2: Found another alternative workaround. Geez. Just fix the augmented operators. What's the point of having them when they cause this error half the time. |