-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pattern completeness: Handle structures under union constructors
The following now generates a correct counterexample: ``` enum E = {A, B} struct Foo = { bar : E } val main : unit -> unit function main() = { let x : Foo = struct { bar = B }; match Some(x) { Some(struct { bar = A }) => (), None() => (), } } ``` whereas previously it would just mark the pattern as potentially incomplete and continue.
- Loading branch information
Showing
4 changed files
with
38 additions
and
1 deletion.
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,6 @@ | ||
[93mWarning[0m: Incomplete pattern match statement at [96mwarn_struct_under_option.sail[0m:14.4-9: | ||
14[96m |[0m match Some(x) { | ||
[91m |[0m [91m^---^[0m | ||
[91m |[0m | ||
The following expression is unmatched: [93mSome(struct { bar = B })[0m | ||
|
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,18 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
$include <option.sail> | ||
|
||
enum E = {A, B} | ||
|
||
struct Foo = { bar : E } | ||
|
||
val main : unit -> unit | ||
|
||
function main() = { | ||
let x : Foo = struct { bar = B }; | ||
match Some(x) { | ||
Some(struct { bar = A }) => (), | ||
None() => (), | ||
} | ||
} |