-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate.hs: Disallow variable shadowing in rules.
In a rule like this: ``` Bar(x+y) :- Foo(x, y), var y = x. ``` there are two legitimate choices for handling the re-introduction of variable `y` in the second clause: (1) let the new declaration shadow the existing one in the rest of then rule, and (2) fail. The existing implementation did neither of those an generated invalid Rust code instead. This commit implements option 2. Note that we already allow variable shadowing inside expressions, but this does not seem like a good choice in a rule scope. Rules contain implicit variable declarations (e.g., variable `x` above), making shadowing extra confusing for users. We therefore err on the side of caution and simply disallow such conflicting declarations.
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 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