From e5316d0bb7e689f98434b88770acbf83db6de5d3 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 6 Nov 2019 00:24:36 +0100 Subject: [PATCH] :bug: Fix auto ptr stmt --- src/import/cdef.c | 8 +++++++- src/lib/ptr.c | 2 +- src/parse/check.c | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/import/cdef.c b/src/import/cdef.c index d277d095..c2d235ae 100644 --- a/src/import/cdef.c +++ b/src/import/cdef.c @@ -52,8 +52,11 @@ ANN2(1) void gwi_class_xtor(const Gwi gwi, const f_xtor ctor, const f_xtor dtor) mk_xtor(gwi->gwion->mp, t, (m_uint)dtor, ae_flag_dtor); } -ANN static Type type_finish(const Gwi gwi, const Type t) { +ANN static inline void gwi_type_flag(const Type t) { SET_FLAG(t, scan1 | ae_flag_scan2 | ae_flag_check | ae_flag_emit); +} + +ANN static Type type_finish(const Gwi gwi, const Type t) { gwi_add_type(gwi, t); import_class_ini(gwi->gwion->env, t); return t; @@ -78,6 +81,8 @@ ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent SET_FLAG(t, typedef); if(ck.tmpl) SET_FLAG(t, template); + else + gwi_type_flag(t); return type_finish(gwi, t); } @@ -85,6 +90,7 @@ ANN Type gwi_class_spe(const Gwi gwi, const m_str name, const m_uint size) { CHECK_OO(str2sym(gwi, name)) const Type t = new_type(gwi->gwion->mp, ++gwi->gwion->env->scope->type_xid, name, NULL); t->size = size; + gwi_type_flag(t); return type_finish(gwi, t); } diff --git a/src/lib/ptr.c b/src/lib/ptr.c index 42ad77e5..e26911c6 100644 --- a/src/lib/ptr.c +++ b/src/lib/ptr.c @@ -113,7 +113,7 @@ GWION_IMPORT(ptr) { GWI_BB(gwi_item_ini(gwi, "@internal", "@val")) GWI_BB(gwi_item_end(gwi, 0, NULL)) GWI_BB(gwi_class_end(gwi)) - t_ptr->nspc->info->offset = SZ_INT; // TODO: should be an assert + t_ptr->nspc->info->offset = SZ_INT; GWI_BB(gwi_oper_ini(gwi, (m_str)OP_ANY_TYPE, "Ptr", NULL)) GWI_BB(gwi_oper_add(gwi, opck_ptr_assign)) GWI_BB(gwi_oper_emi(gwi, opem_ptr_assign)) diff --git a/src/parse/check.c b/src/parse/check.c index 7ba64b30..ee100fc6 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1039,7 +1039,8 @@ ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { td.array = &array; } ptr = known_type(env, &td); - assert(GET_FLAG(ptr, checked)); + if(!GET_FLAG(ptr, checked) && ptr->e->def) + CHECK_BB(traverse_cdef(env, ptr->e->def)) } t = depth ? array_type(env, ptr, depth) : ptr; stmt->v = new_value(env->gwion->mp, t, s_name(stmt->sym)); -- 2.43.0