-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compile-time match literals and options (#3903)
This PR makes constant expressions fully matchable. We now also cover - `LitP` and - `OptP` in the matching machinery. Thus there is no need to differentiate if the pattern is irrefutable. Simplifies the logic quite a bit (as it should!) ----------- TODO - [x] tests for const `Opt` and `Lit` - [x] bottoming cases too - [x] check that `Opt` shortcutting works as intended — already in `iter-no-alloc.mo` for kernel present and `aardvark.mo` for kernel missing.
- Loading branch information
Showing
22 changed files
with
181 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
refuted-const-float.mo:2.5-2.9: execution error, value 3.140_000_000_000_000_1 does not match pattern |
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 @@ | ||
Return code 1 |
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,4 @@ | ||
refuted-const-float.mo:2.5-2.9: warning [M0145], this pattern of type | ||
Float | ||
does not cover value | ||
_ |
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,10 @@ | ||
pattern failed | ||
Error: failed to run main module `_out/refuted-const-float.wasm` | ||
|
||
Caused by: | ||
0: failed to invoke command default | ||
1: wasm trap: unreachable | ||
wasm backtrace: | ||
0: init | ||
1: _start | ||
|
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 @@ | ||
Return code 134 |
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 @@ | ||
refuted-const-option-null.mo:2.5-2.7: execution error, value null does not match pattern |
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 @@ | ||
Return code 1 |
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,4 @@ | ||
refuted-const-option-null.mo:2.5-2.7: warning [M0145], this pattern of type | ||
Null | ||
does not cover value | ||
null |
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,10 @@ | ||
pattern failed | ||
Error: failed to run main module `_out/refuted-const-option-null.wasm` | ||
|
||
Caused by: | ||
0: failed to invoke command default | ||
1: wasm trap: unreachable | ||
wasm backtrace: | ||
0: init | ||
1: _start | ||
|
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 @@ | ||
Return code 134 |
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 @@ | ||
refuted-const-option.mo:2.5-2.9: execution error, value ?42 does not match pattern |
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 @@ | ||
Return code 1 |
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,4 @@ | ||
refuted-const-option.mo:2.5-2.9: warning [M0145], this pattern of type | ||
?Nat | ||
does not cover value | ||
?(_) |
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,10 @@ | ||
pattern failed | ||
Error: failed to run main module `_out/refuted-const-option.wasm` | ||
|
||
Caused by: | ||
0: failed to invoke command default | ||
1: wasm trap: unreachable | ||
wasm backtrace: | ||
0: init | ||
1: _start | ||
|
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 @@ | ||
Return code 134 |
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,11 @@ | ||
// a failing pattern match that can be compiled to a trap | ||
let 0.67 = 3.14; | ||
|
||
// CHECK: (func $init (type | ||
// CHECK: call $blob_of_principal | ||
// CHECK: i32.const 14 | ||
// CHECK-NEXT: call $print_ptr | ||
// CHECK-NEXT: unreachable) | ||
|
||
//SKIP run-low | ||
//SKIP run-ir |
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,11 @@ | ||
// a failing pattern match that can be compiled to a trap | ||
let ?b = null; | ||
|
||
// CHECK: (func $init (type | ||
// CHECK: call $blob_of_principal | ||
// CHECK: i32.const 14 | ||
// CHECK-NEXT: call $print_ptr | ||
// CHECK-NEXT: unreachable) | ||
|
||
//SKIP run-low | ||
//SKIP run-ir |
Oops, something went wrong.