summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-06-30 02:17:48 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-30 23:15:23 -0700
commit0c7eb9f0d093a78520e5cff889dc3fd9d7f6d4c7 (patch)
treeb4ac5ede1f9d47f20e384efb691f30899df0e3dd
parent09a34baac6757c7a4c33e3e3c50054acbb1b70bb (diff)
downloadmc-0c7eb9f0d093a78520e5cff889dc3fd9d7f6d4c7.tar.gz
Support union constants
-rw-r--r--6/simp.c5
-rw-r--r--test/constunion.myr7
-rw-r--r--test/tests1
3 files changed, 13 insertions, 0 deletions
diff --git a/6/simp.c b/6/simp.c
index 3e5213e..400b6bc 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1424,6 +1424,10 @@ static void extractsub(Simp *s, Node *e)
for (i = 0; i < e->expr.nargs; i++)
extractsub(s, e->expr.args[i]);
break;
+ case Oucon:
+ if (e->expr.nargs == 2)
+ extractsub(s, e->expr.args[1]);
+ break;
default:
break;
}
@@ -1447,6 +1451,7 @@ static void simpconstinit(Simp *s, Node *dcl)
case Oarr:
case Ostruct:
case Oslice:
+ case Oucon:
extractsub(s, e);
lappend(&s->blobs, &s->nblobs, dcl);
break;
diff --git a/test/constunion.myr b/test/constunion.myr
new file mode 100644
index 0000000..d8c6ac5
--- /dev/null
+++ b/test/constunion.myr
@@ -0,0 +1,7 @@
+use std
+
+const x = `std.Some "thing"
+
+const main = {
+ std.put("{}\n", x)
+}
diff --git a/test/tests b/test/tests
index b19f482..ba4e075 100644
--- a/test/tests
+++ b/test/tests
@@ -45,6 +45,7 @@ B structasn E 42
B structarray E 42
B structret E 42
B constslice P 2312345678
+B constunion P '`std.Some thing'
B exportmain E 42
B slalloc E 123
B neststruct E 3