-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Error: Type error. Expecting an integral type" error when assigning an enum value with a constexpr with 4.2.0, while generation is correct with 4.1.1 #2783
Comments
Ironically this is due to the improvements in type deduction in .4.2.0 - the internal typecode for the expression
I'll investigate. This change could just be reverted for 4.2.1 if I don't get to the bottom of this before then. |
Thanks a lot @ojwb ! |
Thanks for the great reproducer! I've worked out the reason this grammar rule fires at least - it's what parses |
Fixed.
Actually we don't currently deduce the return type of a function call - it's more complicated than it might initially seem as it can vary between overloaded forms, consider:
Here we need to look at the types of the parameters passed in a call like We could probably handle the case where there's no overloading (or where there is but the return type is always the same) more easily. |
Thanks a lot @ojwb ! Indeed I just tested and your change also fixes the real world code base from which I extracted the reproducer, for reference: |
If I try to wrap with SWIG a C++ enum whose value is assigned by a constexpr function, the generation fails with:
error.
Minimum Reproducible Example
If you create a
testswig.i
file with content (I know that the resulting generated code would not work, I just tried to keep the example file as small as possible):and compile it with:
in swig <= 4.1.1 everything works fine, while in swig==4.2.0 one gets the error:
The text was updated successfully, but these errors were encountered: