You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
The text was updated successfully, but these errors were encountered:
This is an interesting one.. Yeah I think if you'd asked me what I'd expect to happen I would say the Python one would be correct in that sx hasn't been defined - this is the route I think we should probably go here too
I gave the example of Python as a comparison of what it looks like in other languages.
Python's optional arguments behave very weirdly overall if you provide as value a mutable type, like a list. They retain state, which is not ideal to say the least.
Javascript in this case gives us what we'd expect.
Though, looking at the bytecode DEFINE_OPTIONAL itself, it'll need some big rework, because it breaks immediately if the value of the optional arguments isn't just a constant/number/string.
Python's optional arguments behave very weirdly overall if you provide as value a mutable type, like a list. They retain state, which is not ideal to say the least.
I guess it makes sense as it's reference to the same list object each call, so if you mutate, it's gonna mutate 🤷
Though, looking at the bytecode DEFINE_OPTIONAL itself, it'll need some big rework, because it breaks immediately if the value of the optional arguments isn't just a constant/number/string.
I'm not entirely sure what you mean here? In dictu you can pass any value as an optional param not just those types
Is there an existing issue for this?
Current Behavior
Given this function declaration with various optional arguments:
We can see that the optional argument
sy
changed 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
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:
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 fixThe text was updated successfully, but these errors were encountered: