From: fennecdjay Date: Wed, 21 Dec 2022 10:46:10 +0000 (+0100) Subject: :bug: better unions X-Git-Tag: nightly~207^2~25 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=38105cb9cab7c2dbcf412fb2f6a93748543f4f2b;p=gwion.git :bug: better unions --- diff --git a/src/lib/union.c b/src/lib/union.c index 420e46ff..5384f2cb 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -64,7 +64,9 @@ static OP_CHECK(opck_union_is) { const Exp e = (Exp)data; const Exp_Call *call = &e->d.exp_call; const Exp exp = call->args; - if (exp->exp_type != ae_exp_primary && exp->d.prim.prim_type != ae_prim_id) + if(!exp) + ERR_N(e->pos, "Union.is() takes one argument of form id"); + if (exp->exp_type != ae_exp_primary || exp->d.prim.prim_type != ae_prim_id) ERR_N(exp->pos, "Union.is() argument must be of form id"); const Type t = call->func->d.exp_dot.base->type; const Value v = find_value(t, exp->d.prim.d.var); @@ -109,7 +111,7 @@ static OP_CHECK(opck_union_new) { ERR_N(call->func->pos, "Union constructor takes two arguments, " "'id' and 'value'"); if (name->exp_type != ae_exp_primary || name->d.prim.prim_type != ae_prim_id) - return NULL; + return env->gwion->type[et_error]; const Exp val = name->next; const Type base = call->func->d.exp_dot.base->type; const Map map = &base->nspc->info->value->map; @@ -131,7 +133,7 @@ static OP_CHECK(opck_union_new) { return base; } } - return NULL; + return env->gwion->type[et_error]; } ANN GWION_IMPORT(union) {