ref: 0c7eb9f0d093a78520e5cff889dc3fd9d7f6d4c7
parent: 09a34baac6757c7a4c33e3e3c50054acbb1b70bb
author: Michael Forney <mforney@mforney.org>
date: Thu Jun 29 22:17:48 EDT 2017
Support union constants
--- a/6/simp.c
+++ b/6/simp.c
@@ -1424,6 +1424,10 @@
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 @@
case Oarr:
case Ostruct:
case Oslice:
+ case Oucon:
extractsub(s, e);
lappend(&s->blobs, &s->nblobs, dcl);
break;
--- /dev/null
+++ b/test/constunion.myr
@@ -1,0 +1,7 @@
+use std
+
+const x = `std.Some "thing"
+
+const main = {
+ std.put("{}\n", x)
+}
--- a/test/tests
+++ b/test/tests
@@ -45,6 +45,7 @@
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