summaryrefslogtreecommitdiff
path: root/test/nestucon.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-01-16 11:08:35 -0500
committerOri Bernstein <ori@eigenstate.org>2014-01-16 11:08:35 -0500
commit0855d34c6585b6479f74f059a91c483c58016ea8 (patch)
tree2f9c11c293224b585da1639e87bca63d7325f230 /test/nestucon.myr
parente1dd87b2721b7b42e252d83330798e73daf48a27 (diff)
downloadmc-0855d34c6585b6479f74f059a91c483c58016ea8.tar.gz
Install ucons for nested unions.
This allows unions that are defined inline (eg, within a struct) to be created: type t = struct foo : union `Bar `Baz ;; ;; Now has properly installed ucons. Before this change, the union constructors would all have an id of 0, which would lead to them all being collapsed to the first entry.
Diffstat (limited to 'test/nestucon.myr')
-rw-r--r--test/nestucon.myr18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/nestucon.myr b/test/nestucon.myr
new file mode 100644
index 0000000..1939000
--- /dev/null
+++ b/test/nestucon.myr
@@ -0,0 +1,18 @@
+use std
+
+type t = struct
+ x : union
+ `Int int
+ `Str byte[:]
+ ;;
+;;
+
+const main = {
+ var a : t
+
+ a = [.x = `Str "asdf"]
+ match a
+ | [.x=`Str s]: std.put("%s\n", s)
+ ;;
+}
+