-
Notifications
You must be signed in to change notification settings - Fork 126
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
Panic with local definiton that uses constraint guards without a type signature #1685
Comments
This issue involves Two ways we could fix this:
I am leaning more towards option (1), since this is the sort of thing that we could easily detect (and reject) in the parser, well before we get to the typechecker. |
Yeah, I also think (1) is the way to go. |
Numeric constraint guards have very particular syntactic requirements: * They must always be used in top-level definitions. * Their definitions must always be accompanied by a top-level type signature. Previously, we checked these requirements in a combination of places in the parser and the typechecker. The checks in the typechecker weren't very thorough, however, and they failed to catch local definitions without type signatures that use constraint guards, as seen in #1685. This patch moves all of these syntactic checks to the parser (in `Cryptol.Parser.ExpandPropGuards`). We now recurse into expressions to check for local definition that use constraint guards and error if we encounter one. This ensures that by the time we reach the typechecker, all constraint guard expressions are at least syntactically valid. Fixes #1685.
If you give this Cryptol this program:
Then Cryptol will panic:
Note that making slight changes to the program will change the panic to a proper Cryptol error message:
If you give
g
a type signature:Then Cryptol will error thusly:
If you use constraint guards at the top level without a type signature, as in this program:
Then Cryptol will error thusly:
The text was updated successfully, but these errors were encountered: