From: fennecdjay Date: Wed, 31 Jan 2024 20:42:13 +0000 (+0100) Subject: :fire: few fixes X-Git-Tag: nightly~107 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=018811026488ae90ea41127cd79e49e8ce108687;p=gwion.git :fire: few fixes --- diff --git a/src/lib/object_op.c b/src/lib/object_op.c index d5ec3eed..ee25d9cb 100644 --- a/src/lib/object_op.c +++ b/src/lib/object_op.c @@ -264,9 +264,10 @@ OP_EMIT(opem_object_dot) { emit_member(emit, value, exp_getvar(exp_self(member))); else emit_struct_data(emit, value, exp_getvar(exp_self(member))); - } else if (GET_FLAG(value, static)) + } else { + assert(GET_FLAG(value, static)); emit_dot_static_import_data(emit, value, exp_getvar(exp_self(member))); - else exit(3); //emit_pushimm(emit, (m_uint)value->type); + } if(isa(value->type, emit->gwion->type[et_object]) > 0 && !exp_getvar(exp_self(member)) && (GET_FLAG(value, static) || GET_FLAG(value, late))) diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 8128841c..55c90a6b 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -322,7 +322,7 @@ ANN static Type cdef_parent(const Env env, const Class_Def cdef) { } if (tmpl_base(cdef->base.tmpl)) return get_parent_base(env, cdef->base.ext); const bool tmpl = !!cdef->base.tmpl; - if (tmpl) template_push_types(env, cdef->base.tmpl); + if (tmpl) CHECK_BO(template_push_types(env, cdef->base.tmpl)); const Type t = scan0_final(env, cdef->base.ext); if (tmpl) nspc_pop_type(env->gwion->mp, env->curr); return t; diff --git a/src/parse/spread.c b/src/parse/spread.c index 79b81ffa..e01f7b14 100644 --- a/src/parse/spread.c +++ b/src/parse/spread.c @@ -18,8 +18,8 @@ ANN m_bool spread_ast(const Env env, const Spread_Def spread, const Tmpl *tmpl) for(uint32_t i = tmpl->list->len - 1; i < tmpl->call->len; i++) { fseek(f, 0, SEEK_SET); const TmplArg targ = *mp_vector_at(tmpl->call, TmplArg, i); - // skip or error on const? - // or do smth else? + // post spread const expression won't reach here + assert(targ.type == tmplarg_td); DECL_OB(const Type, t, = known_type(env, targ.d.td)); struct AstGetter_ arg = {env->name, f, env->gwion->st, .ppa = env->gwion->ppa}; const m_str type = type2str(env->gwion, t, targ.d.td->tag.loc); @@ -75,8 +75,8 @@ ANN Ast spread_class(const Env env, const Ast body) { { ++offset; break; - } - mp_vector_add(env->gwion->mp, &new_body, Section, section); + } + mp_vector_add(env->gwion->mp, &new_body, Section, section); } } else { if(!acc) @@ -112,7 +112,6 @@ ANN Stmt_List spread_func(const Env env, const Stmt_List body) { const Stmt stmt = *mp_vector_at(list, Stmt, j); mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt); } - break; } } else { mp_vector_add(env->gwion->mp, &new_body, Stmt, stmt); diff --git a/src/parse/template.c b/src/parse/template.c index 27375076..17f581d3 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -166,15 +166,16 @@ static ANN bool is_single_variadic(const MP_Vector *v) { return !strcmp(s_name(spec->tag.sym), "..."); } + ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t loc, const bool is_spread) { if (!sl || sl->len > tl->len || (tl->len != sl->len && !is_spread)) ERR_B(loc, "invalid template type number"); for (uint32_t i = 0; i < sl->len; i++) { - TmplArg *arg = mp_vector_at(tl, TmplArg, i); + TmplArg *targ = mp_vector_at(tl, TmplArg, i); Specialized *spec = mp_vector_at(sl, Specialized, i); - if(arg->type == tmplarg_td) { + if(targ->type == tmplarg_td) { if(spec->td) { - Type_Decl *base = arg->d.td; + Type_Decl *base = targ->d.td; Type_Decl *next = base; Type_Decl *last = next->next; while(next && last) { @@ -186,9 +187,9 @@ ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Speciali next->next = NULL; const Type t = known_type(env, base); if(t) { - arg->type = tmplarg_exp; + targ->type = tmplarg_exp; Exp* e = new_exp_td(env->gwion->mp, base, base->tag.loc); - arg->d.exp = new_exp_dot(env->gwion->mp, e, last->tag.sym, base->tag.loc); + targ->d.exp = new_exp_dot(env->gwion->mp, e, last->tag.sym, base->tag.loc); free_type_decl(env->gwion->mp, last); i--; continue; @@ -199,7 +200,7 @@ ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Speciali spec->td ? "constant" : "type"); } - DECL_OB(const Type, t, = known_type(env, arg->d.td)); + DECL_OB(const Type, t, = known_type(env, targ->d.td)); if(spec->traits) { Symbol missing = miss_traits(t, spec); if (missing) { @@ -246,7 +247,8 @@ ANN static Type _scan_type(const Env env, const Type t, Type_Decl *td) { Specialized_List sl = tmpl ? tmpl->list : NULL; const bool is_spread = is_spread_tmpl(tmpl); - if(!single_variadic) CHECK_BO(check_tmpl(env, tl, sl, td->tag.loc, is_spread)); + if(!single_variadic) + CHECK_BO(check_tmpl(env, tl, sl, td->tag.loc, is_spread)); struct Op_Import opi = {.op = insert_symbol("class"), .lhs = t, .data = (uintptr_t)&ts, diff --git a/tests/new/ref.gw b/tests/new/ref.gw index 8c7cba9c..9557ded6 100644 --- a/tests/new/ref.gw +++ b/tests/new/ref.gw @@ -1 +1 @@ -new Object => var Object? o; +new Object :=> var Object? o; diff --git a/tests/spread/spread_error.gw b/tests/spread/spread_error.gw index b5903bdf..2bf50fb7 100644 --- a/tests/spread/spread_error.gw +++ b/tests/spread/spread_error.gw @@ -3,7 +3,7 @@ class C:[...] { ... T : arg { - zvar T arg; + var T arg; }...