-
-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add implicit null checks to pattern matching (see #2580)
- Loading branch information
Showing
2 changed files
with
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package unit.issues; | ||
|
||
private enum T { | ||
T1(x:Null<T>); | ||
T2(x:Int); | ||
} | ||
|
||
class Issue2580 extends Test { | ||
function test() { | ||
function match(t) { | ||
return switch (t) { | ||
case T1(T1(_)): 0; | ||
case T1(T2(_)): 1; | ||
case T1(_): 2; | ||
case T2(_): 3; | ||
} | ||
} | ||
eq(0, match(T1(T1(null)))); | ||
eq(1, match(T1(T2(1)))); | ||
eq(2, match(T1(null))); | ||
eq(3, match(T2(2))); | ||
} | ||
} |