summaryrefslogtreecommitdiff
path: root/test/typecheck
diff options
context:
space:
mode:
authorAlasdair2019-11-05 20:03:28 +0000
committerAlasdair2019-11-05 20:08:28 +0000
commit03cda7bbb5dccd6d6be4bc9c5d11fcaef5031e18 (patch)
treed9949c5243e0d05789d1460270a3a7adab419580 /test/typecheck
parentd474f256c7dfde3af9ef089ad9de5b7ff01f2d9f (diff)
Forbid types declared after a scattered union being used in clauses
The following is therefore always forbidden ``` scattered union U enum E = A | B | C union clause U = Ctor : E ``` We attempt to detect when this occurs and include a hint indicating the likely reason why a 'Undefined type E' error might occur in this circumstance
Diffstat (limited to 'test/typecheck')
-rw-r--r--test/typecheck/fail/scattered_union_rec.expect16
-rw-r--r--test/typecheck/fail/scattered_union_rec.sail6
2 files changed, 22 insertions, 0 deletions
diff --git a/test/typecheck/fail/scattered_union_rec.expect b/test/typecheck/fail/scattered_union_rec.expect
new file mode 100644
index 00000000..cbc9f70a
--- /dev/null
+++ b/test/typecheck/fail/scattered_union_rec.expect
@@ -0,0 +1,16 @@
+Type error:
+[scattered_union_rec.sail]:6:24-25
+6 |union clause U = Ctor : E
+  | ^
+  | Undefined type E
+  | This error was caused by:
+  | [scattered_union_rec.sail]:6:0-25
+  | 6 |union clause U = Ctor : E
+  |  |^-----------------------^
+  |  | Types are not well-formed within this type definition. Note that recursive types are forbidden.
+  | This error was caused by:
+  | [scattered_union_rec.sail]:6:13-14
+  | 6 |union clause U = Ctor : E
+  |  | ^
+  |  | As this is a scattered union clause, this could also be caused by using a type defined after the 'scattered union' declaration
+  |
diff --git a/test/typecheck/fail/scattered_union_rec.sail b/test/typecheck/fail/scattered_union_rec.sail
new file mode 100644
index 00000000..9f005f4e
--- /dev/null
+++ b/test/typecheck/fail/scattered_union_rec.sail
@@ -0,0 +1,6 @@
+
+scattered union U
+
+enum E = A | B | C
+
+union clause U = Ctor : E