Closed jschueller closed 1 month ago
Thanks for spotting this before the release.
The value is now stored in the parse tree in a canonical form (so false
-> 0
, true
-> 1
) and is then converted to True
/False
based on the argument's type (which should be better as it means we consistently handle cases where the value type isn't the same as the argument's type, such as void f(bool x = 1, int y = false)
).
However we need to strip qualifiers before checking if the type is bool
when deciding whether to convert back.
I have a fix working but need to go out for a bit - will clean up and push later today.
Looks like it affects Ruby too, which has similar code to Python here. The other languages which use numval
effectively check it with SwigType_type(t) == T_BOOL
which strips qualifiers so works already.
thanks
since 9cba248beccc1ec38d58fea03cfd5639eef6fa1f swig emits wrong code for this simple function (in c++ to Python mode):
calling the variant without any argument result in an error at runtime, here for Python (did not test other languages):
weirdly, if I remove the const or make the second argument an int the error goes away
Looks like it could affect other languages as well:
This non-regression test could be added in Examples/test-suite/default_arg_values.i
/cc @ojwb