From: fennecdjay Date: Tue, 30 Jan 2024 12:32:44 +0000 (+0100) Subject: :art: ast cleaning X-Git-Tag: nightly~118 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=bc1291b0e8aaf0a09d465e9b05c6ad9f9c628066;p=gwion.git :art: ast cleaning --- diff --git a/ast b/ast index 9250ae0e..0ba7b3b1 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 9250ae0ec3f65a9be684a5dfb66ca13c7916883f +Subproject commit 0ba7b3b15cbdfab20b35b8a84dcebded0501c054 diff --git a/fmt b/fmt index 0bd98c85..1884860f 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit 0bd98c85e182ecb27324be5298629feef0e05042 +Subproject commit 1884860fc01b25f295cd7c5e7ddc304a1a69e730 diff --git a/include/clean.h b/include/clean.h index 2769eb76..5185a2c0 100644 --- a/include/clean.h +++ b/include/clean.h @@ -11,7 +11,7 @@ typedef struct { } Clean; ANN static void clean_array_sub(Clean *a, Array_Sub b); -ANN static void clean_type_list(Clean *a, Type_List b); +ANN static void clean_tmplarg_list(Clean *a, TmplArg_List b); ANN static void clean_tmpl(Clean *a, Tmpl *b); ANN static void clean_range(Clean *a, Range *b); ANN static void clean_type_decl(Clean *a, Type_Decl *b); diff --git a/include/env/type.h b/include/env/type.h index a5cd0f3a..e18d2981 100644 --- a/include/env/type.h +++ b/include/env/type.h @@ -68,7 +68,7 @@ ANEW ANN Type type_copy(MemPool, const Type type); ANN Value find_value(const Type, const Symbol); ANN m_bool isa(const Type, const Type) __attribute__((pure)); ANN m_bool isres(const Env, const Tag); -ANN Type array_type(const Env, const Type, const m_uint); +ANN Type array_type(const Env, const Type, const m_uint, const loc_t); ANN Type find_common_anc(const Type, const Type) __attribute__((pure)); ANN Type array_base(Type) __attribute__((pure)); ANN Symbol array_sym(const Env env, const Type src, diff --git a/include/import/checker.h b/include/import/checker.h index 7f229d22..7fb8036c 100644 --- a/include/import/checker.h +++ b/include/import/checker.h @@ -49,7 +49,7 @@ ANN Type_Decl *str2td(const Gwion, const m_str, const loc_t); ANN Type str2type(const Gwion, const m_str, const loc_t); // those functions return a mp_alloced string -ANEW ANN m_str tl2str(const Gwion, const Type_List, const loc_t); +ANEW ANN m_str tl2str(const Gwion, const TmplArg_List, const loc_t); ANEW ANN m_str type2str(const Gwion, const Type, const loc_t); ANN static inline Type_Decl *type2td(const Gwion gwion, const Type t, diff --git a/include/template.h b/include/template.h index 47f2d20a..136bd400 100644 --- a/include/template.h +++ b/include/template.h @@ -2,7 +2,7 @@ #define __TEMPLATE ANN m_bool template_push_types(const Env, const Tmpl *); ANN m_bool template_push(const Env env, const Type t); -ANN Tmpl *mk_tmpl(const Env, const Tmpl *, const Type_List); +ANN Tmpl *mk_tmpl(const Env, const Tmpl *, const TmplArg_List); /* //! returns the Tmpl of a class or enum def ANN static inline Tmpl* get_tmpl(const Type t) { diff --git a/include/tmp_resolve.h b/include/tmp_resolve.h index 113566f1..4fa0185a 100644 --- a/include/tmp_resolve.h +++ b/include/tmp_resolve.h @@ -3,5 +3,5 @@ ANN Func find_template_match(const Env env, const Value value, Exp_Call *const exp); ANN Func find_func_match(const Env env, const Func up, Exp_Call *const exp); -ANN2(1,2) m_bool check_tmpl(const Env env, const Type_List tl, const Specialized_List sl, const loc_t pos, const bool is_spread); +ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t pos, const bool is_spread); #endif diff --git a/include/tmpl_info.h b/include/tmpl_info.h index 68188db4..25237bf1 100644 --- a/include/tmpl_info.h +++ b/include/tmpl_info.h @@ -12,5 +12,5 @@ struct tmpl_info { }; ANN Type tmpl_exists(const Env env, struct tmpl_info *const info); -ANN bool tmpl_global(const Env env, Type_List tl); +ANN bool tmpl_global(const Env env, TmplArg_List tl); #endif diff --git a/plug b/plug index 3597b6e3..04994e9d 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 3597b6e30bcbfb85a1fa65346ecf78b3c2231f61 +Subproject commit 04994e9dbc6acf0ff93c78c772a73ce4aab56b0e diff --git a/src/clean.c b/src/clean.c index 0a232814..e67b94a6 100644 --- a/src/clean.c +++ b/src/clean.c @@ -13,7 +13,7 @@ ANN static void clean_array_sub(Clean *a, Array_Sub b) { #define clean_id_list(a, b) do {} while(0) #define clean_specialized_list(a, b) do {} while(0) -ANN static void clean_type_list(Clean *a, Type_List b) { +ANN static void clean_tmplarg_list(Clean *a, TmplArg_List b) { for(uint32_t i = 0; i < b->len; i++) { TmplArg arg = *mp_vector_at(b, TmplArg, i); if(arg.type == tmplarg_td) @@ -25,7 +25,7 @@ ANN static void clean_type_list(Clean *a, Type_List b) { ANN static void clean_tmpl(Clean *a, Tmpl *b) { if (!b->call) clean_specialized_list(a, b->list); - else clean_type_list(a, b->call); + else clean_tmplarg_list(a, b->call); } ANN static void clean_range(Clean *a, Range *b) { @@ -35,7 +35,7 @@ ANN static void clean_range(Clean *a, Range *b) { ANN static void clean_type_decl(Clean *a, Type_Decl *b) { if (b->array) clean_array_sub(a, b->array); - if (b->types) clean_type_list(a, b->types); + if (b->types) clean_tmplarg_list(a, b->types); if (b->fptr) clean_fptr_def(a, b->fptr); if (b->next) clean_type_decl(a, b->next); } @@ -162,14 +162,14 @@ ANN static void clean_stmt_for(Clean *a, Stmt_For b) { } ANN static void clean_idx(Clean *a, struct EachIdx_ *b) { - if (b->v) value_remref(b->v, a->gwion); + if (b->var.value) value_remref(b->var.value, a->gwion); } ANN static void clean_stmt_each(Clean *a, Stmt_Each b) { ++a->scope; clean_exp(a, b->exp); clean_stmt(a, b->body); - if (b->v) mp_free(a->gwion->mp, Value, b->v); + if (b->var.value) mp_free(a->gwion->mp, Value, b->var.value); if (b->idx) clean_idx(a, b->idx); --a->scope; } diff --git a/src/emit/emit.c b/src/emit/emit.c index a8131760..e8203b93 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -372,13 +372,13 @@ static m_bool extend_indices(const Emitter emit, Exp e, const m_uint depth) { return GW_OK; } -ANEW ANN static ArrayInfo *new_arrayinfo(const Emitter emit, const Type t) { +ANEW ANN static ArrayInfo *new_arrayinfo(const Emitter emit, const Type t, const loc_t loc) { const Type base = array_base(t); ArrayInfo *info = mp_calloc(emit->gwion->mp, ArrayInfo); vector_init(&info->type); info->depth = get_depth(t); for (long i = 1; i < info->depth; ++i) - vector_add(&info->type, (vtype)array_type(emit->env, base, i)); + vector_add(&info->type, (vtype)array_type(emit->env, base, i, loc)); vector_add(&info->type, (vtype)t); info->base = base; return info; @@ -398,7 +398,7 @@ ANN2(1, 2) static ArrayInfo *emit_array_extend_inner(const Emitter emit, const Type t, const Exp e, const uint is_ref) { CHECK_BO(extend_indices(emit, e, get_depth(t))); - ArrayInfo * info = new_arrayinfo(emit, t); + ArrayInfo * info = new_arrayinfo(emit, t, t->info->cdef->base.tag.loc); const Instr alloc = emit_add_instr(emit, ArrayAlloc); alloc->m_val = (m_uint)info; if (!is_ref) CHECK_BO(arrayinfo_ctor(emit, info)); @@ -1762,10 +1762,10 @@ ANN m_bool emit_exp_spork(const Emitter emit, const Exp_Unary *unary) { Capture_List caps = sporker.captures; for (uint32_t i = 0; i < caps->len; i++) { Capture *cap = mp_vector_at(caps, Capture, i); - const Value v = cap->orig; + const Value v = cap->var.value; struct Exp_ exp = { .d = { .prim = { - .d = { .var = cap->tag.sym }, + .d = { .var = cap->var.tag.sym }, .value = v, .prim_type = ae_prim_id }}, @@ -2233,18 +2233,18 @@ ANN static m_bool _emit_stmt_each(const Emitter emit, const Stmt_Each stmt, ? */emit_local(emit, emit->gwion->type[et_int]) /*: emit_local(emit, stmt->idx->v->type)*/; - const m_uint val_offset = emit_localn(emit, stmt->v->type); // localn ? + const m_uint val_offset = emit_localn(emit, stmt->var.value->type); // localn ? emit_regtomem(emit, arr_offset, 0); emit_memsetimm(emit, key_offset, -1); - stmt->v->from->offset = val_offset; + stmt->var.value->from->offset = val_offset; //value_addref(stmt->v); -_nspc_add_value(emit->env->curr, stmt->tag.sym, stmt->v); - emit_debug(emit, stmt->v); +_nspc_add_value(emit->env->curr, stmt->tag.sym, stmt->var.value); + emit_debug(emit, stmt->var.value); if (stmt->idx) { - stmt->idx->v->from->offset = key_offset; -_nspc_add_value(emit->env->curr, stmt->idx->tag.sym, stmt->idx->v); + stmt->idx->var.value->from->offset = key_offset; +_nspc_add_value(emit->env->curr, stmt->idx->var.tag.sym, stmt->idx->var.value); //value_addref(stmt->idx->v); - emit_debug(emit, stmt->idx->v); + emit_debug(emit, stmt->idx->var.value); } struct Looper loop = {.exp = stmt->exp, .stmt = stmt->body, @@ -2317,7 +2317,7 @@ ANN static m_bool _emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt, if (stmt->idx) { emit_memsetimm(emit, emit_local(emit, emit->gwion->type[et_int]), 0); emit_memsetimm(emit, offset, -1); - stmt->idx->v->from->offset = offset; + stmt->idx->var.value->from->offset = offset; } CHECK_BB(emit_exp_pop_next(emit, stmt->cond)); emit_regmove(emit, -SZ_INT); diff --git a/src/env/func.c b/src/env/func.c index b7840aa8..1df80f62 100644 --- a/src/env/func.c +++ b/src/env/func.c @@ -41,7 +41,7 @@ ANN void builtin_func(const Gwion gwion, const Func f, void *func_ptr) { f->code->native_func = (m_uint)func_ptr; f->code->ret_type = f->def->base->ret_type; if(f->def->base->tmpl) { - const Type_List tl = f->def->base->tmpl->call; + const TmplArg_List tl = f->def->base->tmpl->call; if(!tl) return; const Specialized *spec = mp_vector_at(f->def->base->tmpl->list, Specialized, f->def->base->tmpl->list->len - 1); if(!strcmp(s_name(spec->tag.sym), "...")) { diff --git a/src/env/type.c b/src/env/type.c index 8975393b..9df5af53 100644 --- a/src/env/type.c +++ b/src/env/type.c @@ -90,14 +90,15 @@ ANN /*static */ Symbol array_sym(const Env env, const Type src, return insert_symbol(name); } -ANN Type array_type(const Env env, const Type src, const m_uint depth) { +ANN Type array_type(const Env env, const Type src, const m_uint depth, const loc_t loc) { if(!depth) return src; const Symbol sym = array_sym(env, src, depth); const Type type = nspc_lookup_type1(src->info->value->from->owner, sym); if (type) return type; const size_t tdepth = depth + src->array_depth; - const Type base = tdepth > 1 ? array_type(env, src, tdepth - 1) : src; - struct TemplateScan ts = {.t = base, /*.td=td*/ }; + const Type base = tdepth > 1 ? array_type(env, src, tdepth - 1, loc) : src; + const Type_Decl td = { .tag = MK_TAG(insert_symbol(src->name), loc) }; + struct TemplateScan ts = {.t = base, .td=&td }; struct Op_Import opi = {.op = insert_symbol("class"), .lhs = env->gwion->type[et_array], .data = (uintptr_t)&ts}; diff --git a/src/import/import_cdef.c b/src/import/import_cdef.c index be1871a7..8da4fc23 100644 --- a/src/import/import_cdef.c +++ b/src/import/import_cdef.c @@ -85,7 +85,7 @@ Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) { Tmpl *tmpl = ck.sl ? new_tmpl(gwi->gwion->mp, ck.sl) : NULL; if (tmpl) CHECK_BO(template_push_types(gwi->gwion->env, tmpl)); DECL_OO(const Type, base, = known_type(gwi->gwion->env, td)); - const Type_List tl = td->types; + const TmplArg_List tl = td->types; if (tflag(base, tflag_ntmpl)) td->types = NULL; const Type p = !td->types ? known_type(gwi->gwion->env, td) : NULL; td->types = tl; diff --git a/src/import/import_checker.c b/src/import/import_checker.c index abb3ff85..87e5378e 100644 --- a/src/import/import_checker.c +++ b/src/import/import_checker.c @@ -125,7 +125,7 @@ ANN m_bool check_typename_def(const Gwi gwi, ImportCK *ck) { } ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc); -ANN bool str2tl(const Gwion gwion, struct td_checker *tdc, Type_List *tl) { +ANN bool str2tl(const Gwion gwion, struct td_checker *tdc, TmplArg_List *tl) { // we probably need smth better if(isalpha(*tdc->str)) { TmplArg targ = { @@ -143,23 +143,23 @@ ANN bool str2tl(const Gwion gwion, struct td_checker *tdc, Type_List *tl) { return true; } -ANN static Type_List td_tmpl(const Gwion gwion, struct td_checker *tdc) { +ANN static TmplArg_List td_tmpl(const Gwion gwion, struct td_checker *tdc) { if (*tdc->str != ':') return NULL; // GW_PASS ++tdc->str; if (*tdc->str != '[') { GWION_ERR(tdc->pos, "invalid character"); - return (Type_List)GW_ERROR; + return (TmplArg_List)GW_ERROR; } ++tdc->str; - Type_List tl = new_mp_vector(gwion->mp, TmplArg, 0); + TmplArg_List tl = new_mp_vector(gwion->mp, TmplArg, 0); if (!str2tl(gwion, tdc, &tl)) { - free_type_list(gwion->mp, tl); - return (Type_List)GW_ERROR; + free_tmplarg_list(gwion->mp, tl); + return (TmplArg_List)GW_ERROR; } if (tdc->str[0] != ']') { - free_type_list(gwion->mp, tl); + free_tmplarg_list(gwion->mp, tl); GWION_ERR(tdc->pos, "unfinished template"); - return (Type_List)GW_ERROR; + return (TmplArg_List)GW_ERROR; } ++tdc->str; return tl; @@ -193,8 +193,8 @@ ANN static Type_Decl *str2td_fptr(const Gwion gwion, struct td_checker *tdc) { const m_str base = tdc->str; tdc->str++; Type_Decl *const ret_td = _str2td(gwion, tdc); - const Type_List tl = td_tmpl(gwion, tdc); - if (tl == (Type_List)GW_ERROR) { + const TmplArg_List tl = td_tmpl(gwion, tdc); + if (tl == (TmplArg_List)GW_ERROR) { free_type_decl(gwion->mp, ret_td); return NULL; } @@ -202,19 +202,19 @@ ANN static Type_Decl *str2td_fptr(const Gwion gwion, struct td_checker *tdc) { tdc->str++; Arg_List args = fptr_args(gwion, tdc); if (args == (Arg_List)GW_ERROR) { - if(tl) free_type_list(gwion->mp, tl); + if(tl) free_tmplarg_list(gwion->mp, tl); free_type_decl(gwion->mp, ret_td); return NULL; } if(tdc->str[0] != ')' || tdc->str[1] != ')') { - if(tl) free_type_list(gwion->mp, tl); + if(tl) free_tmplarg_list(gwion->mp, tl); if(args) free_arg_list(gwion->mp, args); return NULL; } tdc->str += 2; struct AC ac = {.str = tdc->str, .pos = tdc->pos}; if(ac_run(gwion, &ac) < 0 ) { - if(tl) free_type_list(gwion->mp, tl); + if(tl) free_tmplarg_list(gwion->mp, tl); if(args) free_arg_list(gwion->mp, args); return NULL; } @@ -237,17 +237,17 @@ ANN static Type_Decl *_str2td(const Gwion gwion, struct td_checker *tdc) { return td; } DECL_OO(const Symbol, sym, = __str2sym(gwion, tdc)); - Type_List tl = td_tmpl(gwion, tdc); + TmplArg_List tl = td_tmpl(gwion, tdc); struct AC ac = {.str = tdc->str, .pos = tdc->pos}; CHECK_BO(ac_run(gwion, &ac)); tdc->str = ac.str; - if (tl == (Type_List)GW_ERROR) return NULL; + if (tl == (TmplArg_List)GW_ERROR) return NULL; const uint option = get_n(tdc, '?'); Type_Decl *next = NULL; if (*tdc->str == '.') { ++tdc->str; if (!(next = _str2td(gwion, tdc))) { - if (tl) free_type_list(gwion->mp, tl); + if (tl) free_tmplarg_list(gwion->mp, tl); if (ac.base) free_exp(gwion->mp, ac.base); return NULL; } @@ -279,7 +279,7 @@ ANN Type str2type(const Gwion gwion, const m_str str, const loc_t pos) { } struct td_info { - Type_List tl; + TmplArg_List tl; Gwfmt *fmt; }; @@ -304,7 +304,7 @@ ANN Exp td2exp(const MemPool mp, const Type_Decl *td) { ANN static m_bool td_info_run(const Env env, struct td_info *info) { const Gwion gwion = env->gwion; - Type_List tl = info->tl; + TmplArg_List tl = info->tl; for(uint32_t i = 0; i < tl->len; i++) { if (i) text_add(&info->fmt->ls->text, ","); TmplArg *targ = mp_vector_at(tl, TmplArg, i); @@ -345,7 +345,7 @@ ANEW ANN m_str type2str(const Gwion gwion, const Type t, return text.str; } -ANEW ANN m_str tl2str(const Gwion gwion, const Type_List tl, +ANEW ANN m_str tl2str(const Gwion gwion, const TmplArg_List tl, const loc_t pos NUSED) { struct GwfmtState ls = {.minimize=true, .ppa = gwion->ppa}; text_init(&ls.text, gwion->mp); diff --git a/src/lib/array.c b/src/lib/array.c index 589d12a3..f0cd2eee 100644 --- a/src/lib/array.c +++ b/src/lib/array.c @@ -293,8 +293,8 @@ ANN static void cast_end(const Emitter emit, const Type base, const m_uint depth const Instr loop = (Instr)vector_at(&emit->code->instr, pc); loop->m_val = emit_code_size(emit); const Instr end = emit_add_instr(emit, ArrayInit); - const Type t = array_type(emit->env, base, i + 1); - end->m_val = (m_uint)array_type(emit->env, base, i + 1); + const Type t = array_type(emit->env, base, i + 1, base->info->cdef->base.tag.loc); + end->m_val = (m_uint)array_type(emit->env, base, i + 1, base->info->cdef->base.tag.loc); end->m_val2 = t->actual_size ?: t->size; } } @@ -382,7 +382,7 @@ static OP_CHECK(opck_array) { while ((e = e->next)); const Type t = get_array_type(array->type); if (t->array_depth >= array->depth) - return array_type(env, array_base(t), t->array_depth - array->depth); + return array_type(env, array_base(t), t->array_depth - array->depth, array->exp->pos); const Exp curr = take_exp(array->exp, t->array_depth); struct Array_Sub_ next = {curr->next, array_base(t), @@ -887,12 +887,12 @@ ANN static inline Type foreach_type(const Env env, const Exp exp) { DECL_OO(const Type, t, = array_base_simple(base)); if(!tflag(base, tflag_ref)) { const m_uint depth = base->array_depth - 1; - return depth ? array_type(env, t, depth) : t; + return depth ? array_type(env, t, depth, exp->pos) : t; } const Type inner = (Type)vector_front(&base->info->tuple->contains); const Type refbase = array_base_simple(inner); const m_uint depth = inner->array_depth - 1; - return depth ? array_type(env, refbase, depth) : refbase; + return depth ? array_type(env, refbase, depth, exp->pos) : refbase; } // rewrite me diff --git a/src/lib/closure.c b/src/lib/closure.c index 53b275a1..148f9e71 100644 --- a/src/lib/closure.c +++ b/src/lib/closure.c @@ -77,13 +77,13 @@ static OP_CHECK(opck_fptr_call) { } ANN Type upvalue_type(const Env env, Capture *cap) { - const Value v = nspc_lookup_value1(env->curr, cap->tag.sym); - if(!v) ERR_O(cap->tag.loc, _("non existing value")); // did_you_mean + const Value v = nspc_lookup_value1(env->curr, cap->var.tag.sym); + if(!v) ERR_O(cap->var.tag.loc, _("non existing value")); // did_you_mean if(cap->is_ref && not_upvalue(env, v)) - ERR_O(cap->tag.loc, _("can't take ref of a scoped value")); - cap->orig = v; + ERR_O(cap->var.tag.loc, _("can't take ref of a scoped value")); + cap->var.value = v; const Type base_type = !tflag(v->type, tflag_ref) ? v->type : (Type)vector_front(&v->type->info->tuple->contains); - return !cap->is_ref ? base_type : ref_type(env->gwion, base_type, cap->tag.loc); + return !cap->is_ref ? base_type : ref_type(env->gwion, base_type, cap->var.tag.loc); } ANN void free_captures(const VM_Shred shred, m_bit *const caps) { @@ -129,9 +129,9 @@ ANN static m_bool emit_fptr_assign(const Emitter emit, const Type lhs, const Typ Exp e = new_prim_id(emit->gwion->mp, fdef->base->tag.sym, fdef->base->tag.loc); // free me for(uint32_t i = 0; i < captures->len; i++) { Capture *const cap = mp_vector_at(captures, Capture, i); - e->d.prim.d.var = cap->tag.sym; - e->d.prim.value = cap->orig; - e->type = cap->orig->type; + e->d.prim.d.var = cap->var.tag.sym; + e->d.prim.value = cap->var.value; + e->type = cap->var.value->type; exp_setvar(e, cap->is_ref); CHECK_BB(emit_exp(emit, e)); if(!cap->is_ref && tflag(cap->temp->type, tflag_compound)) @@ -162,7 +162,7 @@ struct FptrInfo { ANN static void _fptr_tmpl_push(const Env env, const Func f) { const Tmpl *tmpl = f->def->base->tmpl; if (!tmpl) return; - Type_List tl = tmpl->call; + TmplArg_List tl = tmpl->call; if (!tl) return; Specialized_List sl = tmpl->list; for(uint32_t i = 0; i < sl->len; i++) { @@ -287,11 +287,11 @@ ANN static m_bool _check_lambda(const Env env, Exp_Lambda *l, // here move to arguments for(uint32_t i = 0; i < l->def->captures->len; i++) { Capture *cap = mp_vector_at(l->def->captures, Capture, i); - const Value v = nspc_lookup_value1(env->curr, cap->tag.sym); - if(!v) ERR_B(cap->tag.loc, _("unknown value in capture")); + const Value v = nspc_lookup_value1(env->curr, cap->var.tag.sym); + if(!v) ERR_B(cap->var.tag.loc, _("unknown value in capture")); DECL_OB(const Type, t, = upvalue_type(env, cap)); - cap->temp = new_value(env, t, s_name(cap->tag.sym), cap->tag.loc); - cap->orig = v; + cap->temp = new_value(env, t, s_name(cap->var.tag.sym), cap->var.tag.loc); + cap->var.value = v; } } @@ -660,7 +660,7 @@ static FREEARG(freearg_dottmpl) { #include "traverse.h" #include "gwi.h" -ANN static bool is_base(const Env env, const Type_List tl) { +ANN static bool is_base(const Env env, const TmplArg_List tl) { for(uint32_t i = 0; i < tl->len; i++) { // can call with const happen? TmplArg arg = *mp_vector_at(tl, TmplArg, i); @@ -682,7 +682,7 @@ static OP_CHECK(opck_closure_scan) { Func_Base *const fbase = new_func_base(env->gwion->mp, cpy_type_decl(env->gwion->mp, base->td), info.name, args, ae_flag_none, base->tag.loc); fbase->tmpl = cpy_tmpl(env->gwion->mp, base->tmpl); if(!is_base(env, ts->td->types)) - fbase->tmpl->call = cpy_type_list(env->gwion->mp, ts->td->types); + fbase->tmpl->call = cpy_tmplarg_list(env->gwion->mp, ts->td->types); const Fptr_Def fdef = new_fptr_def(env->gwion->mp, cpy_func_base(env->gwion->mp, fbase)); fdef->base->tag.sym = info.name; struct EnvSet es = {.env = env, diff --git a/src/lib/dict.c b/src/lib/dict.c index bcce4b6a..78bd06b5 100644 --- a/src/lib/dict.c +++ b/src/lib/dict.c @@ -517,10 +517,10 @@ static INSTR(DictEachIdx) { static OP_EMIT(opem_dict_each) { Looper *loop = (Looper *)data; HMapInfo *const hinfo = (HMapInfo*)loop->exp->type->nspc->class_data; - if(loop->idx && !loop->init) loop->idx->v->from->offset = emit_localn(emit, hinfo->key); + if(loop->idx && !loop->init) loop->idx->var.value->from->offset = emit_localn(emit, hinfo->key); const Instr instr = emit_add_instr(emit, !loop->idx ? DictEach : DictEachIdx); instr->m_val2 = loop->offset; - if(loop->idx) instr->m_val = loop->idx->v->from->offset; + if(loop->idx) instr->m_val = loop->idx->var.value->from->offset; if(loop->n)instr->m_val2 += SZ_INT; const Instr go = emit_add_instr(emit, BranchNeqInt); if(!loop->n) loop->instr = go; @@ -569,7 +569,7 @@ static OP_CHECK(opck_dict_scan) { const Class_Def cdef = cpy_class_def(env->gwion->mp, env->gwion->type[et_dict]->info->cdef); cdef->base.ext = type2td(env->gwion, env->gwion->type[et_dict], ts->td->tag.loc); cdef->base.tag.sym = info.name; - cdef->base.tmpl->call = cpy_type_list(env->gwion->mp, info.td->types); + cdef->base.tmpl->call = cpy_tmplarg_list(env->gwion->mp, info.td->types); const bool is_global = tmpl_global(env, ts->td->types); const m_uint scope = is_global ? env_push_global(env) : env->scope->depth; diff --git a/src/lib/instr.c b/src/lib/instr.c index de050607..6ad98c81 100644 --- a/src/lib/instr.c +++ b/src/lib/instr.c @@ -25,7 +25,7 @@ ANN static Func_Def traverse_tmpl(const Emitter emit, Func_Def fdef, Func_Def fb v->d.func_ref->def->d.dl_func_ptr = NULL; // why const Func_Def def = cpy_func_def(env->gwion->mp, v->d.func_ref->def); if (vflag(v, vflag_builtin)) v->d.func_ref->def->d.dl_func_ptr = xfun; - def->base->tmpl->call = cpy_type_list(env->gwion->mp, fbase->base->tmpl->call); + def->base->tmpl->call = cpy_tmplarg_list(env->gwion->mp, fbase->base->tmpl->call); CHECK_BO(traverse_dot_tmpl(emit, def, v)); if (vflag(v, vflag_builtin)) builtin_func(emit->gwion, def->base->func, xfun); return def; diff --git a/src/lib/prim.c b/src/lib/prim.c index 222db81d..cf344ee1 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -195,7 +195,7 @@ static OP_CHECK(opck_int_range) { const Exp exp = (Exp)data; const Range *range = exp->d.prim.d.range; const Exp e = range->start ?: range->end; - return array_type(env, e->type, 1); + return array_type(env, e->type, 1, e->pos); } static OP_EMIT(opem_int_range) { diff --git a/src/lib/tmpl_info.c b/src/lib/tmpl_info.c index a1d387a6..067b75b0 100644 --- a/src/lib/tmpl_info.c +++ b/src/lib/tmpl_info.c @@ -72,7 +72,7 @@ ANEW ANN static Symbol template_id(const Env env, return sym; } -ANN static m_bool template_match(Specialized_List sl, Type_List tl) { +ANN static m_bool template_match(Specialized_List sl, TmplArg_List tl) { // uint32_t i = 0; // while ((call = call->next)) i++; //&& (base = base->next)) @@ -97,7 +97,7 @@ ANN Type tmpl_exists(const Env env, struct tmpl_info *const info) { return _tmpl_exists(env, info->name); } -ANN bool tmpl_global(const Env env, Type_List tl) { +ANN bool tmpl_global(const Env env, TmplArg_List tl) { for(uint32_t i = 0; i < tl->len; i++) { TmplArg arg = *mp_vector_at(tl, TmplArg, i); if(unlikely(arg.type == tmplarg_exp)) continue; diff --git a/src/lib/xork.c b/src/lib/xork.c index c02f8b94..5fe5ba37 100644 --- a/src/lib/xork.c +++ b/src/lib/xork.c @@ -42,7 +42,7 @@ static OP_CHECK(opck_spork) { for(uint32_t i = 0; i < unary->captures->len; i++) { Capture *const cap = mp_vector_at(unary->captures, Capture, i); DECL_OO(const Type, t, = upvalue_type(env, cap)); - cap->temp = new_value(env, t, s_name(cap->tag.sym), cap->tag.loc); + cap->temp = new_value(env, t, s_name(cap->var.tag.sym), cap->var.tag.loc); cap->temp->from->offset = offset; offset += cap->temp->type->size; } @@ -55,7 +55,7 @@ static OP_CHECK(opck_spork) { if(unary->captures) { for(uint32_t i = 0; i < unary->captures->len; i++) { Capture *const cap = mp_vector_at(unary->captures, Capture, i); - valid_value(env, cap->tag.sym, cap->temp); + valid_value(env, cap->var.tag.sym, cap->temp); } } const Func f = env->func; diff --git a/src/parse/check.c b/src/parse/check.c index 79858f7f..245b21ca 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -217,7 +217,7 @@ ANN static inline Type prim_array_match(const Env env, Exp e) { do if (check_collection(env, type, e, loc) < 0) err = true; while ((e = e->next)); - if (!err) return array_type(env, array_base_simple(type), type->array_depth + 1); + if (!err) return array_type(env, array_base_simple(type), type->array_depth + 1, loc); env_set_error(env, true); return NULL; } @@ -541,22 +541,22 @@ static ANN Type check_exp_slice(const Env env, const Exp_Slice *range) { // get the type of the function // without the mangling -ANN static inline Type type_list_base_func(const Type type) { +ANN static inline Type tmplarg_list_base_func(const Type type) { const Nspc owner = type->info->value->from->owner; const Symbol xid = type->info->func->def->base->tag.sym; return nspc_lookup_type0(owner, xid); } -ANN static inline Type type_list_base(const Gwion gwion, const Type type) { - return !(is_func(gwion, type)) ? type : type_list_base_func(type); +ANN static inline Type tmplarg_list_base(const Gwion gwion, const Type type) { + return !(is_func(gwion, type)) ? type : tmplarg_list_base_func(type); } ANN static Type_Decl* mk_td(const Env env, Type_Decl *td, - const Type type, const loc_t pos) { - const Type base = type_list_base(env->gwion, type); + const Type type, const loc_t loc) { + const Type base = tmplarg_list_base(env->gwion, type); const Type t = !td->array ? - base : array_type(env, base, td->array->depth); - return type2td(env->gwion, t, pos); + base : array_type(env, base, td->array->depth, loc); + return type2td(env->gwion, t, loc); } ANN static Type tmplarg_match(const Env env, const Symbol xid, const Symbol tgt, const Type t) { @@ -761,12 +761,12 @@ ANN static Type check_predefined(const Env env, Exp_Call *exp, const Value v, return func->def->base->ret_type; } -ANN static Type_List check_template_args(const Env env, Exp_Call *exp, +ANN static TmplArg_List check_template_args(const Env env, Exp_Call *exp, const Tmpl *tm, const Func_Def fdef) { Specialized_List sl = tm->list; const bool spread = is_spread_tmpl(fdef->base->tmpl); const uint32_t len = sl->len - spread; - Type_List tl = new_mp_vector(env->gwion->mp, TmplArg, len); + TmplArg_List tl = new_mp_vector(env->gwion->mp, TmplArg, len); m_uint args_number = 0; // infer template types from args // should not work with const generic @@ -821,7 +821,7 @@ ANN static Type_List check_template_args(const Env env, Exp_Call *exp, template_arg = template_arg->next; } } - if (args_number < len) //TODO: free type_list + if (args_number < len) //TODO: free tmplarg_list ERR_O(exp->func->pos, _("not able to infer types for template call.")) if(spread) { @@ -851,7 +851,7 @@ ANN static Type check_exp_call_template(const Env env, Exp_Call *exp) { value->d.func_ref ? value->d.func_ref->def : t->info->func->def; Tmpl *tm = fdef->base->tmpl; if (tm->call) return check_predefined(env, exp, value, tm, fdef); - DECL_OO(const Type_List, tl, = check_template_args(env, exp, tm, fdef)); + DECL_OO(const TmplArg_List, tl, = check_template_args(env, exp, tm, fdef)); Tmpl tmpl = {.call = tl}; ((Exp_Call *)exp)->tmpl = &tmpl; DECL_OO(const Func, func, = get_template_func(env, exp, value)); @@ -892,11 +892,11 @@ ANN static Exp check_lambda_captures(const Env env, const Func_Def fdef) { return NULL; } Arg arg = { .var = MK_VAR( - type2td(env->gwion, t, cap->tag.loc), - (Var_Decl){ .tag = MK_TAG(cap->tag.sym, cap->tag.loc) } + type2td(env->gwion, t, cap->var.tag.loc), + (Var_Decl){ .tag = MK_TAG(cap->var.tag.sym, cap->var.tag.loc) } )}; mp_vector_add(env->gwion->mp, &fdef->base->args, Arg, arg); - const Exp exp = new_prim_id(env->gwion->mp, cap->tag.sym, cap->tag.loc); + const Exp exp = new_prim_id(env->gwion->mp, cap->var.tag.sym, cap->var.tag.loc); if(args) tmp = tmp->next = exp; else args = tmp = exp; } @@ -1156,7 +1156,7 @@ ANN2(1) static inline bool is_partial(const Env env, Exp exp) { return false; } -ANN static bool tl_match(const Env env, const Type_List tl0, const Type_List tl1) { +ANN static bool tl_match(const Env env, const TmplArg_List tl0, const TmplArg_List tl1) { if (tl0->len != tl1->len) return false; for(uint32_t i = 0; i < tl0->len; i++) { TmplArg targ0 = *mp_vector_at(tl0, TmplArg, i); @@ -1402,9 +1402,9 @@ ANN static inline m_bool for_empty(const Env env, const Stmt_For stmt) { } ANN static void check_idx(const Env env, const Type base, struct EachIdx_ *const idx) { - idx->v = new_value(env, base, s_name(idx->tag.sym), idx->tag.loc); - valid_value(env, idx->tag.sym, idx->v); - SET_FLAG(idx->v, const); + idx->var.value = new_value(env, base, s_name(idx->var.tag.sym), idx->var.tag.loc); + valid_value(env, idx->var.tag.sym, idx->var.value); + SET_FLAG(idx->var.value, const); } /** sets for the key expression value @@ -1414,7 +1414,7 @@ ANN static m_bool check_each_idx(const Env env, const Exp exp, struct EachIdx_ * .lhs = exp->type, .op = insert_symbol("@each_idx"), .data = (m_uint)exp, - .pos = idx->tag.loc + .pos = idx->var.tag.loc }; DECL_OB(const Type, t, = op_check(env, &opi)); check_idx(env, t, idx); @@ -1438,8 +1438,8 @@ ANN static m_bool do_stmt_each(const Env env, const Stmt_Each stmt) { if (stmt->idx) CHECK_BB(check_each_idx(env, stmt->exp, stmt->idx)); DECL_OB(const Type, ret, = check_each_val(env, stmt->exp)); - stmt->v = new_value(env, ret, s_name(stmt->tag.sym), stmt->tag.loc); - valid_value(env, stmt->tag.sym, stmt->v); + stmt->var.value = new_value(env, ret, s_name(stmt->tag.sym), stmt->tag.loc); + valid_value(env, stmt->tag.sym, stmt->var.value); return check_conts(env, stmt_self(stmt), stmt->body); } @@ -1984,7 +1984,7 @@ ANN m_bool _check_func_def(const Env env, const Func_Def f) { uint32_t offset = fdef->stack_depth; for(uint32_t i = 0; i < fdef->captures->len; i++) { Capture *cap = mp_vector_at(fdef->captures, Capture, i); - valid_value(env, cap->tag.sym, cap->temp); + valid_value(env, cap->var.tag.sym, cap->temp); cap->temp->from->offset = offset; offset += cap->temp->type->size; } diff --git a/src/parse/func_resolve_tmpl.c b/src/parse/func_resolve_tmpl.c index 4aa3f346..d6a8286d 100644 --- a/src/parse/func_resolve_tmpl.c +++ b/src/parse/func_resolve_tmpl.c @@ -19,7 +19,7 @@ struct ResolverArgs { const Value v; Exp_Call *const e; const m_str tmpl_name; - const Type_List types; + const TmplArg_List types; }; ANN static inline Value template_get_ready(const Env env, const Value v, @@ -78,7 +78,7 @@ ANN static Func fptr_match(const Env env, struct ResolverArgs *ra) { CHECK_BO(template_push_types(env, &tmpl)); Func_Base *const fbase = cpy_func_base(env->gwion->mp, base->base); fbase->tag.sym = sym; - fbase->tmpl->call = cpy_type_list(env->gwion->mp, ra->types); + fbase->tmpl->call = cpy_tmplarg_list(env->gwion->mp, ra->types); const Fptr_Def fptr = new_fptr_def(env->gwion->mp, fbase); const Func m_func = ensure_fptr(env, ra, fptr); if (m_func) @@ -101,7 +101,7 @@ ANN static Func create_tmpl(const Env env, struct ResolverArgs *ra, DECL_OO(const Value, value, = template_get_ready(env, ra->v, "template", i)); if (value->d.func_ref->def->builtin) set_vflag(value, vflag_builtin); const Func_Def fdef = cpy_func_def(env->gwion->mp, value->d.func_ref->def); - fdef->base->tmpl->call = cpy_type_list(env->gwion->mp, ra->types); + fdef->base->tmpl->call = cpy_tmplarg_list(env->gwion->mp, ra->types); fdef->vt_index = i; if(is_spread_tmpl(value->d.func_ref->def->base->tmpl)) { @@ -138,7 +138,7 @@ ANN static Func func_match(const Env env, struct ResolverArgs *ra) { ANN static Func find_tmpl(const Env env, const Value v, Exp_Call *const exp, const m_str tmpl_name) { - const Type_List types = exp->tmpl->call; + const TmplArg_List types = exp->tmpl->call; const Func former = env->func; const m_uint scope = env->scope->depth; struct EnvSet es = {.env = env, @@ -177,7 +177,7 @@ ANN static Func __find_template_match(const Env env, const Value v, ANN static Func _find_template_match(const Env env, const Value v, Exp_Call *const exp) { DECL_OO(const Func, f, = __find_template_match(env, v, exp)); - Type_List tl = exp->tmpl->call; + TmplArg_List tl = exp->tmpl->call; Specialized_List sl = f->def->base->tmpl->list; for(uint32_t i = 0; i < tl->len; i++) { Specialized * spec = mp_vector_at(sl, Specialized, i); diff --git a/src/parse/operator.c b/src/parse/operator.c index feb57286..e672faa9 100644 --- a/src/parse/operator.c +++ b/src/parse/operator.c @@ -168,7 +168,7 @@ ANN static inline Type op_parent(const Env env, const Type t) { const Type base = array_base_simple(t); return !base->info->parent ? t->info->parent - : array_type(env, base->info->parent, depth); + : array_type(env, base->info->parent, depth, t->info->cdef->base.tag.loc); } ANN static Type op_check_inner(const Env env, struct OpChecker *ock, @@ -228,7 +228,7 @@ ANN bool tmpl_match(const Env env, const struct Op_Import *opi, return true; } -ANN static void op_tmpl_set(const Gwion gwion, Type_List tl, +ANN static void op_tmpl_set(const Gwion gwion, TmplArg_List tl, const Type t, const loc_t pos, const uint32_t idx) { TmplArg arg = {.type = tmplarg_td, .d = { .td = type2td(gwion, t, pos)}}; mp_vector_set(tl, TmplArg, idx, arg); diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a3a3bd4b..9afa62a4 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -305,9 +305,9 @@ ANN static inline m_bool stmt_each_defined(const restrict Env env, if (nspc_lookup_value1(env->curr, stmt->tag.sym)) ERR_B(stmt_self(stmt)->pos, _("foreach value '%s' is already defined"), s_name(stmt->tag.sym)) - if (stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->tag.sym)) - ERR_B(stmt->idx->tag.loc, _("foreach index '%s' is already defined"), - s_name(stmt->idx->tag.sym)) + if (stmt->idx && nspc_lookup_value1(env->curr, stmt->idx->var.tag.sym)) + ERR_B(stmt->idx->var.tag.loc, _("foreach index '%s' is already defined"), + s_name(stmt->idx->var.tag.sym)) return GW_OK; } @@ -350,7 +350,7 @@ describe_ret_nspc(for, Stmt_For,, !(scan1_stmt(env, stmt->c1) < 0 || scan1_stmt(env, stmt->body) < 0) ? 1 : -1) describe_ret_nspc(each, Stmt_Each,, !(stmt_each_defined(env, stmt) < 0 || scan1_exp(env, stmt->exp) < 0 || scan1_stmt(env, stmt->body) < 0) ? 1 : -1) -describe_ret_nspc(loop, Stmt_Loop,, !( (!stmt->idx ? GW_OK : shadow_var(env, stmt->idx->tag)) < 0 || +describe_ret_nspc(loop, Stmt_Loop,, !( (!stmt->idx ? GW_OK : shadow_var(env, stmt->idx->var.tag)) < 0 || scan1_exp(env, stmt->cond) < 0 || scan1_stmt(env, stmt->body) < 0) ? 1 : -1) @@ -837,7 +837,7 @@ ANN static m_bool scan1_class_def_body(const Env env, const Class_Def cdef) { ANN static m_bool scan1_class_tmpl(const Env env, const Class_Def c) { Specialized_List sl = c->base.tmpl->list; - Type_List tl = c->base.tmpl->call; + TmplArg_List tl = c->base.tmpl->call; env_push_type(env, c->base.type); m_bool ret = GW_OK; // check len diff --git a/src/parse/scan2.c b/src/parse/scan2.c index 74bbffe5..295ffd39 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -590,10 +590,10 @@ ANN m_bool scan2_class_def(const Env env, const Class_Def cdef) { if (c->body) { const m_uint scope = env_push_type(env, t); const Tmpl *tmpl = cdef->base.tmpl; - if(tmpl && tmpl->call && tmpl->call != (Type_List)1 && tmpl->list) + if(tmpl && tmpl->call && tmpl->call != (TmplArg_List)1 && tmpl->list) template_push_types(env, tmpl); const m_bool ret = scan2_class_body(env, c); - if(tmpl && tmpl->call && tmpl->call != (Type_List)1 && tmpl->list) + if(tmpl && tmpl->call && tmpl->call != (TmplArg_List)1 && tmpl->list) nspc_pop_type(env->gwion->mp, env->curr); env_pop(env, scope); return ret; diff --git a/src/parse/scanx.c b/src/parse/scanx.c index 068cd149..3444c9b1 100644 --- a/src/parse/scanx.c +++ b/src/parse/scanx.c @@ -15,7 +15,7 @@ ANN static inline m_bool _body(const Env e, Ast b, const _exp_func f) { } ANN static inline int actual(const Tmpl *tmpl) { - return tmpl->call && tmpl->call != (Type_List)1 && tmpl->list; + return tmpl->call && tmpl->call != (TmplArg_List)1 && tmpl->list; } ANN static inline m_bool tmpl_push(const Env env, const Tmpl *tmpl) { diff --git a/src/parse/template.c b/src/parse/template.c index bea9160a..310a0f60 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -17,7 +17,7 @@ ANN static m_bool _push_types(const Env env, const Nspc nspc, const Tmpl *tmpl) { Specialized_List sl = tmpl->list; - Type_List tl = tmpl->call; + TmplArg_List tl = tmpl->call; Specialized *spec = mp_vector_at(sl, Specialized, sl->len - 1); const uint32_t len = strcmp(s_name(spec->tag.sym), "...") ? sl->len : sl->len-1; @@ -108,9 +108,9 @@ ANN m_bool template_push_types(const Env env, const Tmpl *tmpl) { POP_RET(GW_ERROR); } -ANN Tmpl *mk_tmpl(const Env env, const Tmpl *tm, const Type_List types) { +ANN Tmpl *mk_tmpl(const Env env, const Tmpl *tm, const TmplArg_List types) { Tmpl *tmpl = new_tmpl(env->gwion->mp, tm->list); - tmpl->call = cpy_type_list(env->gwion->mp, types); + tmpl->call = cpy_tmplarg_list(env->gwion->mp, types); return tmpl; } @@ -166,7 +166,7 @@ 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 Type_List tl, const Specialized_List sl, const loc_t pos, const bool is_spread) { +ANN2(1,2) m_bool check_tmpl(const Env env, const TmplArg_List tl, const Specialized_List sl, const loc_t pos, const bool is_spread) { if (!sl || sl->len > tl->len || (tl->len != sl->len && !is_spread)) ERR_B(pos, "invalid template type number"); for (uint32_t i = 0; i < sl->len; i++) { @@ -242,7 +242,7 @@ ANN static Type _scan_type(const Env env, const Type t, Type_Decl *td) { return ret; } struct TemplateScan ts = {.t = t, .td = td}; - Type_List tl = td->types; + TmplArg_List tl = td->types; Specialized_List sl = tmpl ? tmpl->list : NULL; const bool is_spread = is_spread_tmpl(tmpl); @@ -282,7 +282,7 @@ ANN Type scan_type(const Env env, const Type t, Type_Decl *td) { env->context = ctx; env->name = name; if (!td->array) return ret; - return array_type(env, ret, td->array->depth); + return array_type(env, ret, td->array->depth, td->tag.loc); } return !t->array_depth ? _scan_type(env, t, td) : t; } diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index c2435988..56944958 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -12,7 +12,7 @@ ANN static Type _option(const Env env, Type_Decl *td, const uint8_t n) { const Array_Sub array = td->array; td->array = NULL; - Type_List tl = new_mp_vector(env->gwion->mp, TmplArg, 1); + TmplArg_List tl = new_mp_vector(env->gwion->mp, TmplArg, 1); TmplArg arg = { .type = tmplarg_td, .d = { .td = td } }; mp_vector_set(tl, TmplArg, 0, arg); Type_Decl tmp = { .tag = MK_TAG(insert_symbol("Option"), td->tag.loc), .types = tl }; @@ -31,7 +31,7 @@ ANN static Type option(const Env env, Type_Decl *td) { } ANN static Type _ref(const Env env, Type_Decl *td) { - Type_List tl = new_mp_vector(env->gwion->mp, TmplArg, 1); + TmplArg_List tl = new_mp_vector(env->gwion->mp, TmplArg, 1); TmplArg arg = { .type = tmplarg_td, .d = { .td = td } }; mp_vector_set(tl, TmplArg, 0, arg); Type_Decl tmp = {.tag = MK_TAG(insert_symbol("Ref"), td->tag.loc), .types = tl}; @@ -113,7 +113,7 @@ ANN static Type resolve(const Env env, Type_Decl *td) { DECL_OO(const Type, t, = !td->ref ? type : ref(env, td)); DECL_OO(const Type, ret, = !td->option ? t : option(env, td)); const Array_Sub array = last->array; - return !array ? ret : array_type(env, ret, array->depth); + return !array ? ret : array_type(env, ret, array->depth, td->tag.loc); } ANN static inline void *type_unknown(const Env env, const Type_Decl *td) {