From: fennecdjay Date: Fri, 20 Sep 2019 14:47:28 +0000 (+0200) Subject: :art: Improve Union X-Git-Tag: nightly~2215^2~11 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=e74382ccddcdcbd1c318ce488e6d2b18f352f1d3;p=gwion.git :art: Improve Union --- diff --git a/ast b/ast index 1bab5b09..59f14732 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 1bab5b098155c763f48164a1aae5e450797f36b7 +Subproject commit 59f147324289f644940968e3125cef2bde3a3f94 diff --git a/examples/union.gw b/examples/union.gw index a2084721..b20c5517 100644 --- a/examples/union.gw +++ b/examples/union.gw @@ -1,7 +1,6 @@ union { int i; - Object @ o; - + Object o; }; <<< i, " ", o >>>; diff --git a/src/lib/ptr.c b/src/lib/ptr.c index 80d571d2..183a867f 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -34,7 +34,9 @@ static INSTR(instr_ptr_assign) { } static OP_EMIT(opem_ptr_assign) { - emit_add_instr(emit, GWOP_EXCEPT); + const Exp_Binary* bin = (Exp_Binary*)data; + if(!GET_FLAG(bin->rhs->type, nonnull)) + emit_add_instr(emit, GWOP_EXCEPT); return emit_add_instr(emit, instr_ptr_assign); } diff --git a/src/parse/check.c b/src/parse/check.c index f6fbbb71..a9851dc7 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1129,9 +1129,6 @@ ANN m_bool check_union_def(const Env env, const Union_Def udef) { do { CHECK_OB(check_exp(env, l->self)) if(isa(l->self->type, t_object) > 0) { - if(!GET_FLAG(l->self->d.exp_decl.td, ref) && !GET_FLAG(udef->type, template)) - ERR_B(l->self->pos, _("In union, Objects must be declared as reference (use '@')")) -// SET_FLAG(l->self->d.exp_decl.td, ref); Var_Decl_List list = l->self->d.exp_decl.list; do SET_FLAG(list->self->value, pure); while((list = list->next)); diff --git a/tests/error/union_array_empty.gw b/tests/error/union_array_empty.gw index cfc880ea..d62b538d 100644 --- a/tests/error/union_array_empty.gw +++ b/tests/error/union_array_empty.gw @@ -1,5 +1,5 @@ #! [contains] must be defined with empty union { int i; - int @array[4]; + int array[4]; }; diff --git a/tests/error/union_invalid.gw b/tests/error/union_invalid.gw deleted file mode 100644 index b170fa0f..00000000 --- a/tests/error/union_invalid.gw +++ /dev/null @@ -1,5 +0,0 @@ -#! [contains] Unions should only contain declarations - union -{ - one; two; -}; diff --git a/tests/error/union_object_ref.gw b/tests/error/union_object_ref.gw deleted file mode 100644 index e006098d..00000000 --- a/tests/error/union_object_ref.gw +++ /dev/null @@ -1,8 +0,0 @@ -#! [contains] In union, Objects must be declared as reference (use '@') -union -{ - int i; - Object o; - -}; -<<< i, " ", o >>>; diff --git a/tests/match/tuple.c b/tests/match/tuple.gw similarity index 100% rename from tests/match/tuple.c rename to tests/match/tuple.gw