-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for #2415, support for negative literals in match
- Loading branch information
Showing
3 changed files
with
46 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,32 @@ | ||
module Bug2415 | ||
|
||
let sign = (z:int{z = 0 \/ z = (-1) \/ z = 1}) | ||
|
||
let example_1 (s:sign) : string = | ||
match s with | ||
| -1 -> "negative" | ||
| 1 -> "positive" | ||
| 0 -> "zero" | ||
| -2 -> assert False; "" | ||
|
||
open FStar.Int32 | ||
open FStar.Int8 | ||
open FStar.UInt32 | ||
open FStar.UInt8 | ||
|
||
type i8 = FStar.Int8.t | ||
type i32 = FStar.Int32.t | ||
type u8 = FStar.UInt8.t | ||
type u32 = FStar.UInt32.t | ||
|
||
let test1 (n:i32) = | ||
match n with | ||
| -1l -> assert (Int32.v n == -1) | ||
| 1l -> assert (Int32.v n == 1) | ||
| _ -> () | ||
|
||
[@@ expect_failure [114]] // type of pattern (Int32.t) does not match the type of scrutinee (Int8.t) | ||
let test2 (n:i8) = | ||
match n with | ||
| -0l -> () | ||
| _ -> () |
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