From f9bdfe9a210c39bee48183bddc547ca725d20863 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 14 Dec 2020 01:21:16 +0100 Subject: [PATCH] :art: Add var names to unions --- include/import/checker.h | 2 +- include/import/udef.h | 2 +- src/clean.c | 8 +- src/import/import_udef.c | 9 +- src/lib/object_op.c | 2 +- src/lib/union.c | 166 +++------------------ src/parse/operator.c | 10 +- src/parse/scan0.c | 7 +- src/parse/scan1.c | 19 ++- src/parse/scan2.c | 2 +- tests/error/union_array_empty.gw | 5 +- tests/error/union_global_private.gw | 2 +- tests/error/union_global_private_static.gw | 2 +- tests/error/union_global_static.gw | 2 +- tests/plug/array_in_var_name_fail.c | 2 +- tests/plug/union.c | 4 +- tests/plug/union_fail_exp.c | 4 +- tests/plug/union_member.c | 4 +- tests/plug/union_name.c | 4 +- tests/plug/union_tmpl.c | 6 +- tests/plug/union_tmpl_fail.c | 6 +- tests/plug/union_tmpl_fail2.c | 6 +- tests/plug/union_tmpl_fail3.c | 6 +- 23 files changed, 91 insertions(+), 189 deletions(-) diff --git a/include/import/checker.h b/include/import/checker.h index 69a357dd..210fc79a 100644 --- a/include/import/checker.h +++ b/include/import/checker.h @@ -22,7 +22,7 @@ typedef struct ImportCK { // name_checker ? f_xfun addr; }; union { - Type_List list;// union + Union_List list;// union struct Vector_ v; // ID_List curr;// enum }; diff --git a/include/import/udef.h b/include/import/udef.h index a11c1f10..dc25503c 100644 --- a/include/import/udef.h +++ b/include/import/udef.h @@ -2,7 +2,7 @@ #define __IMPORT_UNION ANN2(1) m_int gwi_union_ini(const Gwi gwi, const m_str name); -ANN m_int gwi_union_add(const Gwi gwi, const __restrict__ m_str type); +ANN m_int gwi_union_add(const Gwi gwi, const __restrict__ m_str type, const __restrict__ m_str name); ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag); ANN void ck_clean_udef(MemPool, ImportCK*); diff --git a/src/clean.c b/src/clean.c index 007d6a11..48ba283e 100644 --- a/src/clean.c +++ b/src/clean.c @@ -307,8 +307,14 @@ ANN static void clean_enum_def(Clean *a, Enum_Def b) { vector_release(&b->values); } +ANN static void clean_union_list(Clean *a, Union_List b) { + clean_type_decl(a, b->td); + if(b->next) + clean_union_list(a, b->next); +} + ANN static void clean_union_def(Clean *a, Union_Def b) { - clean_type_list(a, b->l); + clean_union_list(a, b->l); if(b->tmpl) clean_tmpl(a, b->tmpl); } diff --git a/src/import/import_udef.c b/src/import/import_udef.c index af9be60c..029ca26a 100644 --- a/src/import/import_udef.c +++ b/src/import/import_udef.c @@ -31,10 +31,13 @@ ANN m_int gwi_union_ini(const Gwi gwi, const m_str name) { return GW_OK; } -ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type) { +ANN m_int gwi_union_add(const Gwi gwi, const restrict m_str type, const restrict m_str name) { CHECK_BB(ck_ok(gwi, ck_udef)) DECL_OB(Type_Decl*, td, = str2decl(gwi->gwion, type, gwi->loc)) - gwi->ck->list = new_type_list(gwi->gwion->mp, td, gwi->ck->list); + DECL_OB(const Symbol, xid, = str2sym(gwi->gwion, name, gwi->loc)) + const Union_List l = new_union_list(gwi->gwion->mp, td, xid, loc(gwi)); + l->next = gwi->ck->list; + gwi->ck->list = l; return GW_OK; } @@ -73,7 +76,7 @@ ANN Type gwi_union_end(const Gwi gwi, const ae_flag flag) { ANN void ck_clean_udef(MemPool mp, ImportCK* ck) { if(ck->list) - free_type_list(mp, ck->list); + free_union_list(mp, ck->list); if(ck->tmpl) free_id_list(mp, ck->tmpl); } diff --git a/src/lib/object_op.c b/src/lib/object_op.c index c98925d7..519009c2 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -322,7 +322,7 @@ ANN static OP_EMIT(opem_option_uncond) { ANN static m_bool scantmpl_union_def(const Env env, struct tmpl_info *info) { const Union_Def u = info->base->info->udef; - const Union_Def udef = new_union_def(env->gwion->mp, cpy_type_list(env->gwion->mp, u->l), + const Union_Def udef = new_union_def(env->gwion->mp, cpy_union_list(env->gwion->mp, u->l), loc_cpy(env->gwion->mp, u->pos)); udef->xid = info->name; udef->tmpl = mk_tmpl(env, u->tmpl, info->td->types); diff --git a/src/lib/union.c b/src/lib/union.c index e285d03b..1a33a181 100644 --- a/src/lib/union.c +++ b/src/lib/union.c @@ -12,145 +12,41 @@ #include "specialid.h" #include "gack.h" -#define UNION_IDX(a) (*(m_uint*)(a->data)) - static GACK(gack_none) { INTERP_PRINTF("None") } -static OP_CHECK(opck_any_at_union) { - Exp_Binary *bin = (Exp_Binary*)data; - CHECK_NN(opck_rassign(env, data, mut)) // check those two lines - const Type lhs = bin->lhs->info->type; - const Nspc nspc = bin->rhs->info->type->nspc; - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(lhs == *(Type*)(nspc->info->class_data + i)) - return bin->rhs->info->type; - } - return env->gwion->type[et_error]; // err_msg -} - -static inline Type curr_type(const M_Object o) { - const m_uint idx = UNION_IDX(o); - if(!idx) - return NULL; - const Type curr = *(Type*)(o->type_ref->nspc->info->class_data + ((idx-1) * SZ_INT)); - return curr; -} - static INSTR(UnionSet) { - POP_REG(shred, SZ_INT); - const M_Object o = **(M_Object**)REG(0); - memcpy(o->data + SZ_INT, REG(-instr->m_val), instr->m_val); - UNION_IDX(o) = instr->m_val2; - PUSH_REG(shred, SZ_INT-instr->m_val); - *(M_Object*)REG(-SZ_INT) = o; - _release(o, shred); -} - -static OP_EMIT(opem_any_at_union) { - Exp_Binary *bin = (Exp_Binary*)data; - const Type lhs = bin->lhs->info->type; - const Nspc nspc = bin->rhs->info->type->nspc; - const Instr instr = emit_add_instr(emit, UnionSet); - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(lhs == *(Type*)(nspc->info->class_data + i)) { - instr->m_val2 = i/SZ_INT + 1; - instr->m_val = lhs->size; - return instr; - } - } - return NULL; -} - -static OP_CHECK(opck_union_at_any) { - CHECK_NN(opck_rassign(env, data, mut)) // check those two lines - Exp_Binary *bin = (Exp_Binary*)data; - const Type rhs = bin->rhs->info->type; - const Nspc nspc = bin->lhs->info->type->nspc; - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(rhs == *(Type*)(nspc->info->class_data + i)) - return rhs; - } - return env->gwion->type[et_error]; // err_msg -} - -static INSTR(UnionGet) { - const M_Object o = *(M_Object*)REG(-SZ_INT*2); - if(UNION_IDX(o) != instr->m_val2) - Except(shred, "invalid union access"); - memcpy(*(m_bit**)REG(-SZ_INT), o->data + SZ_INT, instr->m_val); - POP_REG(shred, SZ_INT*2 - instr->m_val); - memcpy(REG(-instr->m_val), o->data + SZ_INT, instr->m_val); - _release(o, shred); -} - -static OP_EMIT(opem_union_at_any) { - Exp_Binary *bin = (Exp_Binary*)data; - const Type rhs = bin->rhs->info->type; - const Nspc nspc = bin->lhs->info->type->nspc; - // TODO: compound - const Instr instr = emit_add_instr(emit, UnionGet); - if(isa(rhs, emit->gwion->type[et_object]) > 0) { - const Instr instr = emit_add_instr(emit, RegAddRef); - instr->m_val = -SZ_INT; - } - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(rhs == *(Type*)(nspc->info->class_data + i)) { - instr->m_val2 = i/SZ_INT + 1; - instr->m_val = rhs->size; - return instr; - } - } - return NULL; -} - -static OP_CHECK(opck_union_eq_class) { - Exp_Binary *bin = (Exp_Binary*)data; - const Type rhs = bin->rhs->info->type->info->base_type; - const Nspc nspc = bin->lhs->info->type->nspc; - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(rhs == *(Type*)(nspc->info->class_data + i)) - return env->gwion->type[et_bool]; - } - return NULL; // err_msg + const M_Object o = *(M_Object*)REG(-SZ_INT); + *(m_uint*)o->data = instr->m_val; + memcpy(o->data + SZ_INT, REG(-SZ_INT-instr->m_val2), instr->m_val2); + *(m_bit**)REG(-SZ_INT) = o->data + SZ_INT; } -static INSTR(UnionEqClass) { - POP_REG(shred, SZ_INT); +static INSTR(UnionCheck) { const M_Object o = *(M_Object*)REG(-SZ_INT); - *(m_uint*)REG(-SZ_INT) = (UNION_IDX(o) == instr->m_val2); - _release(o, shred); + if(*(m_uint*)o->data != instr->m_val) + Except(shred, _("invalid union access")) + POP_REG(shred, SZ_INT - instr->m_val2); + memcpy(REG(-instr->m_val2), o->data + SZ_INT, instr->m_val2); } -static OP_EMIT(opem_union_eq_class) { - Exp_Binary *bin = (Exp_Binary*)data; - const Type rhs = bin->rhs->info->type->info->base_type; - const Nspc nspc = bin->lhs->info->type->nspc; - const Instr instr = emit_add_instr(emit, UnionEqClass); - if(!strcmp(s_name(bin->op), "!=")) - (void)emit_add_instr(emit, IntNot); - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - if(rhs == *(Type*)(nspc->info->class_data + i)) { - instr->m_val2 = i/SZ_INT + 1; +static OP_EMIT(opem_union_dot) { + const Exp_Dot *member = (Exp_Dot*)data; + const Map map = &member->t_base->nspc->info->value->map; + for(m_uint i = 0; i < map_size(map); ++i) { + if(VKEY(map, i) == (m_uint)member->xid) { + CHECK_BO(emit_exp(emit, member->base)) + const Instr instr = emit_add_instr(emit, + !exp_getvar(exp_self(member)) ? UnionCheck : UnionSet); + instr->m_val = i + 1; + instr->m_val2 = ((Value)VVAL(map, i))->type->size; return instr; } } return NULL; } -static INSTR(UnionNot) { - const M_Object o = *(M_Object*)REG(-SZ_INT); - const m_uint idx = UNION_IDX(o); - if(idx) { - const Type none = shred->info->vm->gwion->type[et_none]; - const Type curr = *(Type*)(o->type_ref->nspc->info->class_data + ((idx-1) * SZ_INT)); - *(m_uint*)REG(-SZ_INT) = curr == none; - } else - *(m_uint*)REG(-SZ_INT) = 1; - _release(o, shred); -} - static DTOR(UnionDtor) { const m_uint idx = *(m_uint*)o->data; if(idx) { @@ -175,29 +71,13 @@ ANN GWION_IMPORT(union) { GWI_BB(gwi_class_end(gwi)) gwi->gwion->type[et_union] = t_union; - GWI_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "@Union", NULL)) - GWI_BB(gwi_oper_add(gwi, opck_any_at_union)) - GWI_BB(gwi_oper_emi(gwi, opem_any_at_union)) - GWI_BB(gwi_oper_end(gwi, "?=>", NULL)) - GWI_BB(gwi_oper_ini(gwi, "@Union", (m_str)OP_ANY_TYPE, NULL)) - GWI_BB(gwi_oper_add(gwi, opck_union_at_any)) - GWI_BB(gwi_oper_emi(gwi, opem_union_at_any)) - GWI_BB(gwi_oper_end(gwi, "?=>", NULL)) - - GWI_BB(gwi_oper_ini(gwi, "@Union", "@Class", NULL)) - GWI_BB(gwi_oper_add(gwi, opck_union_eq_class)) - GWI_BB(gwi_oper_emi(gwi, opem_union_eq_class)) - GWI_BB(gwi_oper_end(gwi, "==", NULL)) - GWI_BB(gwi_oper_add(gwi, opck_union_eq_class)) - GWI_BB(gwi_oper_emi(gwi, opem_union_eq_class)) - GWI_BB(gwi_oper_end(gwi, "!=", NULL)) - GWI_BB(gwi_oper_ini(gwi, NULL, "@Union", "bool")) - GWI_BB(gwi_oper_end(gwi, "!", UnionNot)) + GWI_BB(gwi_oper_emi(gwi, opem_union_dot)) + GWI_BB(gwi_oper_end(gwi, "@dot", NULL)) GWI_BB(gwi_union_ini(gwi, "Option:[A]")) - GWI_BB(gwi_union_add(gwi, "A")) - GWI_BB(gwi_union_add(gwi, "None")) + GWI_BB(gwi_union_add(gwi, "None", "none")) + GWI_BB(gwi_union_add(gwi, "A", "val")) GWI_BB(gwi_union_end(gwi, ae_flag_none)) return GW_OK; diff --git a/src/parse/operator.c b/src/parse/operator.c index 56089f33..e21530f5 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -265,9 +265,13 @@ ANN Instr op_emit(const Emitter emit, const struct Op_Import* opi) { continue; const M_Operator* mo = operator_find(v, l, r); if(mo) { - if(mo->em) - return mo->em(emit, (void*)opi->data); - return handle_instr(emit, mo); + if(mo->em) { + const Instr ret = mo->em(emit, (void*)opi->data); + if(ret) + return ret; + } + else if(mo->func || mo->instr) + return handle_instr(emit, mo); } } while(r && (r = op_parent(emit->env, r))); } while(l && (l = op_parent(emit->env, l))); diff --git a/src/parse/scan0.c b/src/parse/scan0.c index b66fc18c..223638b6 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -244,9 +244,10 @@ ANN m_bool scan0_union_def(const Env env, const Union_Def udef) { context_global(env); CHECK_BB(scan0_defined(env, udef->xid, udef->pos)) udef->type = union_type(env, udef->xid); - Type_List tl = udef->l; - do udef->type->nspc->info->class_data_size += SZ_INT; - while((tl = tl->next)); + Union_List l = udef->l; + do udef->type->nspc->info->offset += SZ_INT; + while((l = l->next)); + udef->type->nspc->info->offset += SZ_INT; SET_ACCESS(udef, udef->type); if(udef->tmpl) union_tmpl(env, udef); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 1331a2f5..a91a7ec4 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -401,16 +401,21 @@ ANN m_bool scan1_type_def(const Env env, const Type_Def tdef) { ANN static inline m_bool scan1_union_def_inner_loop(const Env env, Union_Def udef) { nspc_allocdata(env->gwion->mp, udef->type->nspc); - Type_List l = udef->l; + Union_List l = udef->l; m_uint sz = 0; - const Nspc nspc = udef->type->nspc; - for(m_uint i = 0; i < nspc->info->class_data_size; i += SZ_INT) { - DECL_OB(const Type, t, =(*(Type*)(nspc->info->class_data + i) = known_type(env, l->td))) + do { + DECL_OB(const Type, t, = known_type(env, l->td)) + if(nspc_lookup_value0(env->curr, l->xid)) + ERR_B(l->pos, _("'%s' already declared in union"), s_name(l->xid)) +// check name +puts(env->curr->name); + const Value v = new_value(env->gwion->mp, t, s_name(l->xid)); + v->from->offset = SZ_INT; + valuefrom(env ,v->from); + nspc_add_value_front(env->curr, l->xid, v); if(t->size > sz) sz = t->size; - l = l->next; - } - nspc->info->offset = sz + SZ_INT; + } while((l = l->next)); return GW_OK; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index a578d1b5..9af08dbf 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -259,7 +259,7 @@ ANN static m_bool scan2_stmt_jump(const Env env, const Stmt_Jump stmt) { return GW_OK; } -ANN m_bool scan2_union_def(const Env env, const Union_Def udef) { +ANN m_bool scan2_union_def(const Env env NUSED, const Union_Def udef) { if(tmpl_base(udef->tmpl)) return GW_OK; set_tflag(udef->type, tflag_scan2); diff --git a/tests/error/union_array_empty.gw b/tests/error/union_array_empty.gw index 0c99543b..c9f63041 100644 --- a/tests/error/union_array_empty.gw +++ b/tests/error/union_array_empty.gw @@ -1,2 +1,5 @@ #! [contains] must be defined with empty -union U { int : int [4] }; +union U { + int i; + int[4] j; +} diff --git a/tests/error/union_global_private.gw b/tests/error/union_global_private.gw index 98f3a2dd..61975b7d 100644 --- a/tests/error/union_global_private.gw +++ b/tests/error/union_global_private.gw @@ -1,2 +1,2 @@ #! [contains] can only be used at class scope. -union static U { int }; +union static U { int i; } diff --git a/tests/error/union_global_private_static.gw b/tests/error/union_global_private_static.gw index 6c0b5b44..f4ef299f 100644 --- a/tests/error/union_global_private_static.gw +++ b/tests/error/union_global_private_static.gw @@ -1,2 +1,2 @@ #! [contains] can only be used at class scope. -union private static U { int }; +union private static U { int i; } diff --git a/tests/error/union_global_static.gw b/tests/error/union_global_static.gw index f1c95c51..834d48b9 100644 --- a/tests/error/union_global_static.gw +++ b/tests/error/union_global_static.gw @@ -1,2 +1,2 @@ #! [contains] can only be used at class scope. -union private U { int }; +union private U { int i; } diff --git a/tests/plug/array_in_var_name_fail.c b/tests/plug/array_in_var_name_fail.c index 6963aaf2..7d4ed74b 100644 --- a/tests/plug/array_in_var_name_fail.c +++ b/tests/plug/array_in_var_name_fail.c @@ -11,6 +11,6 @@ GWION_IMPORT(checker) { GWI_BB(gwi_union_ini(gwi, "U")) - GWI_BB(gwi_union_add(gwi, "int")) + GWI_BB(gwi_union_add(gwi, "int", "i")) return GW_OK; } diff --git a/tests/plug/union.c b/tests/plug/union.c index fe8127af..5dd8357f 100644 --- a/tests/plug/union.c +++ b/tests/plug/union.c @@ -10,8 +10,8 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } diff --git a/tests/plug/union_fail_exp.c b/tests/plug/union_fail_exp.c index fe6645fa..6d4bc044 100644 --- a/tests/plug/union_fail_exp.c +++ b/tests/plug/union_fail_exp.c @@ -10,8 +10,8 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U")) - GWI_BB(gwi_union_add(gwi,"Float")) - GWI_BB(gwi_union_add(gwi,"int")) + GWI_BB(gwi_union_add(gwi,"Float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } diff --git a/tests/plug/union_member.c b/tests/plug/union_member.c index 65e2fcd2..830e3181 100644 --- a/tests/plug/union_member.c +++ b/tests/plug/union_member.c @@ -11,8 +11,8 @@ GWION_IMPORT(union_member) { GWI_OB(gwi_class_ini(gwi, "UnionMember", NULL)) GWI_BB(gwi_union_ini(gwi, "U")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int[]")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int[]", "array")) GWI_OB(gwi_union_end(gwi, ae_flag_none)) GWI_BB(gwi_class_end(gwi)) return GW_OK; diff --git a/tests/plug/union_name.c b/tests/plug/union_name.c index 17cf8856..671280d2 100644 --- a/tests/plug/union_name.c +++ b/tests/plug/union_name.c @@ -10,8 +10,8 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "my_union")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } diff --git a/tests/plug/union_tmpl.c b/tests/plug/union_tmpl.c index 637251b2..83aee39e 100644 --- a/tests/plug/union_tmpl.c +++ b/tests/plug/union_tmpl.c @@ -10,9 +10,9 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) - GWI_BB(gwi_union_add(gwi,"A")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) + GWI_BB(gwi_union_add(gwi,"A", "a")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } diff --git a/tests/plug/union_tmpl_fail.c b/tests/plug/union_tmpl_fail.c index 637251b2..83aee39e 100644 --- a/tests/plug/union_tmpl_fail.c +++ b/tests/plug/union_tmpl_fail.c @@ -10,9 +10,9 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) - GWI_BB(gwi_union_add(gwi,"A")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) + GWI_BB(gwi_union_add(gwi,"A", "a")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } diff --git a/tests/plug/union_tmpl_fail2.c b/tests/plug/union_tmpl_fail2.c index e8310372..cc23bc1b 100644 --- a/tests/plug/union_tmpl_fail2.c +++ b/tests/plug/union_tmpl_fail2.c @@ -10,9 +10,9 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) - GWI_BB(gwi_union_add(gwi,"A")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) + GWI_BB(gwi_union_add(gwi,"A", "a")) GWI_BB(gwi_union_ini(gwi, "U:[A]")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; diff --git a/tests/plug/union_tmpl_fail3.c b/tests/plug/union_tmpl_fail3.c index 637251b2..83aee39e 100644 --- a/tests/plug/union_tmpl_fail3.c +++ b/tests/plug/union_tmpl_fail3.c @@ -10,9 +10,9 @@ GWION_IMPORT(union_test) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) - GWI_BB(gwi_union_add(gwi,"float")) - GWI_BB(gwi_union_add(gwi,"int")) - GWI_BB(gwi_union_add(gwi,"A")) + GWI_BB(gwi_union_add(gwi,"float", "f")) + GWI_BB(gwi_union_add(gwi,"int", "i")) + GWI_BB(gwi_union_add(gwi,"A", "a")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; } -- 2.43.0