goboscript icon indicating copy to clipboard operation
goboscript copied to clipboard

until loop implementation is incorrect with functions

Open faretek1 opened this issue 1 year ago • 1 comments

This script will never end.

costumes "blank.svg";

func add1(v) {
    return $v + 1;
}

onflag{
    i = 0;
    until add1(i) > 10 {
        i++;
    }
}

This is because the implementation for using funcs with until loops is the same for with repeat loops, But it shouldn't be.

The compiled code is as follows:

Image

The function, however, should be called every single iteration. The correct compiled code really should be:

Image

Simply duplicate the same code that is used for 'callsiting' above the until block to the end of the until loop - using the same callsite variable

faretek1 avatar Jan 27 '25 22:01 faretek1

I’d like to work on this issue because I have a solid grasp of AST manipulation and code generation, and I’ve debugged similar control flow issues in compiler/transpiler projects. This bug involves ensuring function calls inside until loops are re-evaluated per iteration, unlike repeat. I’ll analyze the current codegen logic, identify why add1(i) is only evaluated once, and apply the correct callsite duplication strategy to fix the loop behavior. I'll also write a minimal test case to verify proper evaluation. I’m experienced with open-source contributions and excited to improve the language’s reliability.

Jayking40 avatar May 28 '25 16:05 Jayking40