Compiler Memory Access Violation in For/Next Loop
Monkey Forums/Monkey Bug Reports/Compiler Memory Access Violation in For/Next Loop
| ||
Hi, I am new to Monkey and started playing around with the tutorials (typically, I didn't read the documentation first). In doing so, I caused a Memory Access Violation to occur during compilation. I had to close down the IDE and restart it to clear the problem. I shared the code with another developer (experienced in Monkey) and he spotted the mistake I had made. He also encountered the compiler crash bug (running v66b). I had used a float Step in a For/Next loop iterating via an Integer variable. The integer wasn't explicitly declared as in the example below but the crash was the same. Although my problem is fixed, I thought I would report this, as it resulted in a compiler crash rather than a meaningful error message or looping behaviour in the execution of the program. To help with reproducing the bug I have created a minimal example: --- Function Main() For Local i:Int = 0 To 2.5 Step 0.5 Print i Next End --- If you change the "Step 0.5" to Step 1 the problem goes away. Alternatively changing the data type to a Float also clears the problem. Hope this helps to fix a minor issue. |
| ||
I think it's a bit of a programming error rather than a language bug. the problem I see is that you can't step an integer in float increments. you either increment a float in float steps or an int in integer steps. this works: For Local i:Float = 0 to 2.5 step 0.5 and this: For Local i:int = 0 to 2.5 step 1 |
| ||
Fixed in v67 I think - I'll double check later. |
| ||
v67 gives an "Invalid Step Expression" |
| ||
Hey Jessie, I noted in my post that the step was incorrect. I reported this as a Monkey problem because the compiler crashed. Two separate problems really - one definitely me, the other a Monkey bug. Thanks for confirming the fix Mark / Jesse. Cheers, Gary |