-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
file.txt
import system
function Main()
{
name = "test"
PrintLine(name) // Prints "test"
PrintLine(name) // Prints 0
}
When the call block is run, it stores the list items into Call to retrieve later. However, a couple lines later, vars.Clear() is called which also clears the var list and the list in the new Call object.
file.krt
:Main
pushString "test"
setVar name
pushVar name
// Prints "test" but vars in main call object are being cleared when this is run
call PrintLine
// Variable "name" is not found as far and gets pushed with default value "0"
pushVar name
// Prints "0"
call PrintLine
ret
Changing this line to the following will preserve the list when Clear is called:
Call c = new Call(currentFunc, code.pos, new List<Var>(vars));
I know this is meant to be a learning tool and not everything complete, but this would make the variables work the way they were intended to.
Metadata
Metadata
Assignees
Labels
No labels