Is there an existing issue for this?
Current Behavior
Given this function declaration with various optional arguments:
def call(text, x=0, y=0, r=0, sx=15, sy=sx, ox=0, oy=0)
{
print(text, x, y, r, sx, sy, ox, oy);
}
call(1, 2);
We can see that the optional argument sy changed unexpectedly:
1 <- text ok
2 <- x ok
0 <- y ok
0 <- r ok
1 <- sx ok
0 <- sy wrong, it changed to 0?
0 <- ok
0 <- ok
As far as I can tell it could have something to do to with the assignment to a local in the optional sy=sx.
Calling with just 1 as argument doesn't modify the other parameters, the problem seems to start with more arguments given.
Expected Behavior
It should probably let us use safely locals.
The same example in Python directly throws an error telling us name 'sx' is not defined, but optional arguments in Python are already weird to deal with.
On the other hand, Javascript gives us the expected values:
function call(text, x=0, y=0, r=0, sx=1, sy=sx, ox=0, oy=0) {
console.log(text, x, y, r, sx, sy, ox, oy);
}
call(1, 2, 3)
// 1 2 3 0 1 1 0 0
call(1, 2, 3, 4, 5)
// 1 2 3 4 5 5 0 0
Steps To Reproduce
No response
Anything else?
The handling for optional arguments happens in the opcode DEFINE_OPTIONAL in the function declaration, not sure if it can help or if there might be a fix
Is there an existing issue for this?
Current Behavior
Given this function declaration with various optional arguments:
We can see that the optional argument
sychanged unexpectedly:As far as I can tell it could have something to do to with the assignment to a local in the optional
sy=sx.Calling with just
1as argument doesn't modify the other parameters, the problem seems to start with more arguments given.Expected Behavior
It should probably let us use safely locals.
The same example in Python directly throws an error telling us
name 'sx' is not defined, but optional arguments in Python are already weird to deal with.On the other hand, Javascript gives us the expected values:
Steps To Reproduce
No response
Anything else?
The handling for optional arguments happens in the opcode
DEFINE_OPTIONALin the function declaration, not sure if it can help or if there might be a fix