]> Nishi Git Mirror - gwion.git/commitdiff
:art: no refs in union
authorfennecdjay <fennecdjay@gmail.com>
Thu, 15 Dec 2022 13:41:17 +0000 (14:41 +0100)
committerfennecdjay <fennecdjay@gmail.com>
Thu, 15 Dec 2022 13:41:17 +0000 (14:41 +0100)
src/parse/scan1.c
tests/union/union_ref.gw [new file with mode: 0644]

index 449f5a6519513ee46a42e79ba891b4a28d0af94e..eda5c7eafbd86fe16b16ef8503922bdc3dc397c5 100644 (file)
@@ -476,6 +476,8 @@ ANN static inline m_bool scan1_union_def_inner_loop(const Env env,
     DECL_OB(const Type, t, = known_type(env, um->td));
     if (nspc_lookup_value0(env->curr, um->vd.xid))
       ERR_B(um->vd.pos, _("'%s' already declared in union"), s_name(um->vd.xid))
+    if(tflag(t, tflag_ref))
+      ERR_B(um->vd.pos, _("can't declare ref type in union"));
     const Value v = new_value(env, t, s_name(um->vd.xid), um->vd.pos);
     tuple_contains(env, v);
     valuefrom(env, v->from);
diff --git a/tests/union/union_ref.gw b/tests/union/union_ref.gw
new file mode 100644 (file)
index 0000000..c560ebd
--- /dev/null
@@ -0,0 +1,3 @@
+union U {
+  &int i;
+}