diff options
| author | Alasdair Armstrong | 2018-11-20 18:06:47 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-11-20 18:06:47 +0000 |
| commit | 5705c13d1dbe98ee63acc75a0436128e2a7de6e8 (patch) | |
| tree | 40509f5f8dd4a8250b8e8b4978fd3038941f283e | |
| parent | 71020c2f460e6031776df17cf8f2f71df5bb9730 (diff) | |
Add a test case for a struct with a constrained type variable
| -rw-r--r-- | test/typecheck/pass/constrained_struct.sail | 12 | ||||
| -rw-r--r-- | test/typecheck/pass/constrained_struct/v1.expect | 5 | ||||
| -rw-r--r-- | test/typecheck/pass/constrained_struct/v1.sail | 12 |
3 files changed, 29 insertions, 0 deletions
diff --git a/test/typecheck/pass/constrained_struct.sail b/test/typecheck/pass/constrained_struct.sail new file mode 100644 index 00000000..64b2287f --- /dev/null +++ b/test/typecheck/pass/constrained_struct.sail @@ -0,0 +1,12 @@ +default Order dec + +$include <prelude.sail> + +struct MyStruct 'n, 'n in {32, 64} = { + field: bits('n) +} + +type MyStruct32 = MyStruct(32) +type MyStruct64 = MyStruct(64) + +let x : MyStruct64 = struct { field = 0xFFFF_FFFF_FFFF_FFFF } diff --git a/test/typecheck/pass/constrained_struct/v1.expect b/test/typecheck/pass/constrained_struct/v1.expect new file mode 100644 index 00000000..5173ef0b --- /dev/null +++ b/test/typecheck/pass/constrained_struct/v1.expect @@ -0,0 +1,5 @@ +Type error at file "constrained_struct/v1.sail", line 10, character 19 to line 10, character 26 + +type MyStruct64 = [41mMyStruct[0m(65) + +Could not prove (65 = 32 | 65 = 64) for type constructor MyStruct diff --git a/test/typecheck/pass/constrained_struct/v1.sail b/test/typecheck/pass/constrained_struct/v1.sail new file mode 100644 index 00000000..62fc1c01 --- /dev/null +++ b/test/typecheck/pass/constrained_struct/v1.sail @@ -0,0 +1,12 @@ +default Order dec + +$include <prelude.sail> + +struct MyStruct 'n, 'n in {32, 64} = { + field: bits('n) +} + +type MyStruct32 = MyStruct(32) +type MyStruct64 = MyStruct(65) + +let x : MyStruct64 = struct { field = 0b1 @ 0xFFFF_FFFF_FFFF_FFFF } |
