-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compiler crash from
match
with extra parens around let
in tup…
…le (#4595) The compiler would crash if an extra set of parens were added to a single element tuple match of a union type. For example, if `type Foo is (I32 | (I32, I32))` is being matched, then a match clause like `| (123, (let x: I32)) => x` would crash the compiler. This was caused by the codegen for the match not handling the extra SEQ node in the AST created by the parens. This change now skips any extra SEQ nodes when performing codegen for tuple matches. Fixes #4412
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Fix compiler crash from `match` with extra parens around `let` in tuple | ||
|
||
When matching on a tuple element within a union type, the compiler would crash when extra parentheses were present. | ||
|
||
The following code fails to compile because of `(123, (let x: I32))` in the `match`. The extra parentheses should be ignored and treated like `(123, let x: I32)`. | ||
|
||
```pony | ||
let value: (I32 | (I32, I32)) = (123, 42) | ||
match value | ||
| (123, (let x: I32)) => x | ||
end | ||
``` |
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 @@ | ||
42 |
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,14 @@ | ||
use @pony_exitcode[None](code: I32) | ||
|
||
// As long as #4412 is fixed, this program will compile. | ||
|
||
actor Main | ||
new create(env: Env) => | ||
// A union type with a tuple is required to trigger the crash | ||
let z: (I32 | (I32, I32)) = (123, 42) | ||
|
||
match z | ||
// This is the line that triggered the crash due to the extra parens around | ||
// the let. | ||
| (123, (let x: I32)) => @pony_exitcode(x) | ||
end |