-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: fix and repro for issue-4236 (bad renaming of
or
-patterns) (#4244
) Fix `ir_def/rename.ml`, for renaming bound variables, to properly handle our newly extended `or`-patterns. With `or`-patterns, the same variable may have several binding occurrences, so renaming has to treat all of these consistently. Instead of renaming variables on the fly, for `or`-patterns, we now determine the set of bound identifiers bound by all the patterns beneath the `or`, rename them, and substitute consistently within the `or`-pattern to produce the renamed `or`-pattern.
- Loading branch information
Showing
4 changed files
with
87 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// crashes in renaming of or-pattern | ||
// (NB: renaming itself only forced by actor class (to avoid capture when class arg binds parameters) | ||
actor class () { | ||
type Account = { | ||
holder : Principal; | ||
balance : Nat; | ||
}; | ||
type Amount = { | ||
amount : Nat | ||
}; | ||
type Movement = { | ||
#deposit : Account and Amount; | ||
#withdraw : Account and Amount; | ||
}; | ||
|
||
func getAccount(m : Movement) : Account = | ||
switch m { | ||
case (#deposit accnt or #withdraw accnt) accnt | ||
} | ||
} | ||
|
||
//SKIP run | ||
//SKIP run-ir | ||
//SKIP run-low |
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,2 @@ | ||
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 | ||
ingress Completed: Reply: 0x4449444c0000 |