exprTypes doesn't look into operator definitions
#764
RyanGlScott
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The definition of
exprTypesincopilot-c99andcopilot-bluespecis subtly wrong:copilot/copilot-c99/src/Copilot/Compile/C99/Compile.hs
Lines 262 to 275 in 365fb21
In particular, it doesn't recurse into operators in the
Op1,Op2, andOp3cases. This matters because operators have their ownTypefields, which may not be reflected in theExprs fields thatOp1,Op2, andOp3store. When emitting struct declarations incopilot-c99orcopilot-bluespec, it is crucial that everyTypebe considered, as if you miss aType, then it is possible that the generated code may lack a struct declaration, which will cause the resulting code to fail to compile.I am unable to come up with a program in today's Copilot that trips over this bug, but I did discover this when attempting to add a new operator which returns a new struct. The type of this struct is only apparent if you look at the
Typefield in the operator, but it is not reflected in any of the baseExprs.To fix this, I applied the following patch:
Details
All reactions