summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/typecheck/pass/constrained_struct.sail12
-rw-r--r--test/typecheck/pass/constrained_struct/v1.expect5
-rw-r--r--test/typecheck/pass/constrained_struct/v1.sail12
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 = MyStruct(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 }