-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for syntactically invalid constraint guards in the parser
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.
- Loading branch information
1 parent
94c8db0
commit 54f52c5
Showing
11 changed files
with
186 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
f | 0 == 0 => () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:load noTypeSig.cry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Loading module Cryptol | ||
Loading module Cryptol | ||
Loading module Main | ||
|
||
At noTypeSig.cry:1:1--1:2: | ||
Declaration `f` lacks a type signature. | ||
Declarations using constraint guards require an explicit type signature. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// A regression test for #1685. | ||
f : () | ||
f = g | ||
where | ||
g | 0 == 0 => () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:load noTypeSigNested.cry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Loading module Cryptol | ||
Loading module Cryptol | ||
Loading module Main | ||
|
||
At noTypeSigNested.cry:5:5--5:6: | ||
Local declaration `g` may not use constraint guards. | ||
Constraint guards may only appear at the top-level of a module. |