-
Notifications
You must be signed in to change notification settings - Fork 26
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
Bool/Int coercion for C is incomplete #1187
Comments
Another option is to have |
So I tried it, and the CI fails in a few cases, e.g. https://github.com/utwente-fmt/vercors/actions/runs/8803794962/job/24163164935. It seems that coercing the boolean expression of the
TCInt into TInt , preventing any further coercion to/from TBool . I'm not sure why this coercion is done, maybe @sakehl can explain it. For now, I'm not sure whether having _Bool be a TCInt is worth it, or whether it breaks more than it fixes 😕
|
A few thought
This is exactly why I introduced TCInt. So we recognize when we come from a C program, and we want C like coercions between types. The file So if you want to coerce from TCInt to TBool, that is fine. But then you need to add the explicit cast. Probably with CoerceCIntBool()? Or something? Does that help? |
The PR #1170 started implementing a coercion between boolean and integer values in C, since booleans are a type of integer there. It works for simple examples like https://github.com/utwente-fmt/vercors/blob/9b74fd74a18ad232784329ba78fab55d623a1511/examples/technical/intBoolCoercion.c. But for the program below, it still fails on the comparison:
To type-check the
AmbiguousLessEq
operation, theCoercingRewriter
tries to convert both sides toint
. Here,\result
has the typeCPrimitiveType
, which wraps aTBool
. So I tried extending the coercion to this specific combination of types.However, it seems that at some point in the process, the node is assigned the simple type
TBool
. Afterwards, a NopCoercingRewriter tries to cast thisTBool
into anint
, and fails.I'm not sure what the solution here is. I think if we simply allow coercing
TBool
toint
, then this would also enable the coercion in non-C cases, which we probably don't want. But how do we recognise for a specific case that we are working in C and should allow this coercion?The text was updated successfully, but these errors were encountered: