-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pattern Completeness: Warn if no wildcard case for scattered unions (#…
…826)
- Loading branch information
Showing
6 changed files
with
104 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
scattered union U | ||
|
||
union clause U = A : int | ||
|
||
register R : U = A(0) | ||
|
||
union clause U = B : string | ||
|
||
end U | ||
|
||
val foo : unit -> unit | ||
|
||
function foo() = { | ||
match R { | ||
A(0) => (), | ||
A(_) => (), | ||
B(s) => print_endline(s), | ||
} | ||
} |
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_union_open.sail[0m:16.2-7: | ||
16[96m |[0m match R { | ||
[91m |[0m [91m^---^[0m | ||
[91m |[0m | ||
The following expression is unmatched: [93m<future U clause>(undefined)[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,23 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
scattered union U | ||
|
||
union clause U = A : int | ||
|
||
register R : U = A(0) | ||
|
||
union clause U = B : string | ||
|
||
val foo : unit -> unit | ||
|
||
function foo() = { | ||
match R { | ||
A(0) => (), | ||
A(_) => (), | ||
B(s) => print_endline(s), | ||
} | ||
} | ||
|
||
end U |
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_union_open_other.sail[0m:18.2-7: | ||
18[96m |[0m match R { | ||
[91m |[0m [91m^---^[0m | ||
[91m |[0m | ||
The following expression is unmatched: [93mC(undefined)[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,25 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
scattered union U | ||
|
||
union clause U = A : int | ||
|
||
register R : U = A(0) | ||
|
||
union clause U = B : string | ||
|
||
union clause U = C : unit | ||
|
||
val foo : unit -> unit | ||
|
||
function foo() = { | ||
match R { | ||
A(0) => (), | ||
A(_) => (), | ||
B(s) => print_endline(s), | ||
} | ||
} | ||
|
||
end U |