From b76a473c0e958e1abf4329a3ac923dd8d83fd752 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 15 Dec 2022 14:41:17 +0100 Subject: [PATCH] :art: no refs in union --- src/parse/scan1.c | 2 ++ tests/union/union_ref.gw | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 tests/union/union_ref.gw diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 449f5a65..eda5c7ea 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -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 index 00000000..c560ebdc --- /dev/null +++ b/tests/union/union_ref.gw @@ -0,0 +1,3 @@ +union U { + &int i; +} -- 2.43.0