From 8f9501815b02767aa44f7cfa90354a17c3f5a752 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 24 Aug 2019 11:57:01 +0200 Subject: [PATCH] :bug: Fix a few bug [thanks A.F.L] --- src/emit/emit.c | 2 +- src/lib/object.c | 3 ++- src/oo/value.c | 2 +- src/parse/check.c | 6 ++++-- src/parse/scan1.c | 3 +-- src/parse/template.c | 9 ++++++--- src/parse/type_decl.c | 2 +- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 26dc49aa..9c67e35a 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1837,7 +1837,7 @@ ANN static m_bool emit_parent(const Emitter emit, const Class_Def cdef) { const Type base = parent->e->d.base_type; if(base && !GET_FLAG(base, emit)) CHECK_BB(emit_cdef(emit, base->e->def)) - return !GET_FLAG(parent, emit) ? emit_cdef(emit, parent->e->def) : GW_OK; + return !GET_FLAG(parent, emit) ? scanx_parent(parent, emit_cdef, emit) : GW_OK; } ANN static inline m_bool emit_cdef(const Emitter emit, const Class_Def cdef) { diff --git a/src/lib/object.c b/src/lib/object.c index e1c451fe..16d74ec3 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -122,9 +122,10 @@ static OP_CHECK(at_object) { const Type r = bin->rhs->type; if(opck_rassign(env, data, mut) == t_null) return t_null; + if(check_nonnull(env, l, r, "assign", exp_self(bin)->pos) == t_null) + return t_null; if(bin->rhs->exp_type == ae_exp_decl) SET_FLAG(bin->rhs->d.exp_decl.td, ref); - CHECK_OO(check_nonnull(env, l, r, "assign", exp_self(bin)->pos)) bin->rhs->emit_var = 1; return r; } diff --git a/src/oo/value.c b/src/oo/value.c index 7fc89708..70289cea 100644 --- a/src/oo/value.c +++ b/src/oo/value.c @@ -9,7 +9,7 @@ #include "type.h" ANN static void free_value(Value a, Gwion gwion) { - const Type t = !GET_FLAG(a->type, nonnull) ? a->type : a->type->e->parent; + const Type t = a->type; if(!GET_FLAG(a, func) && a->d.ptr && !GET_FLAG(a, union) && !(GET_FLAG(a, enum) && GET_FLAG(a, builtin) && a->owner_class) && isa(t, t_object) < 0) diff --git a/src/parse/check.c b/src/parse/check.c index 1b6a6a57..fb02fe13 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -180,7 +180,7 @@ ANN static inline m_bool not_from_owner_class(const Env env, const Type t, if(!v->owner_class || isa(t, v->owner_class) < 0) { ERR_B(pos, _("'%s' from owner namespace '%s' used in '%s'."), - v->name, v->owner->name, t->name) + v->name, v->owner ? v->owner->name : "?", t->name) } return GW_OK; } @@ -364,6 +364,8 @@ ANN static Type tuple_depth(const Env env, const Array_Sub array) { array->exp->d.exp_primary.primary_type != ae_primary_num) ERR_O(array->exp->pos, _("tuple subscripts must be litteral")) const m_uint idx = array->exp->d.exp_primary.d.num; + if(idx >= vector_size(&array->type->e->tuple->types)) + ERR_O(array->exp->pos, _("tuple subscripts too big")) const Type type = (Type)vector_at(&array->type->e->tuple->types, idx); if(type == t_undefined) ERR_O(array->exp->pos, _("tuple subscripts is undefined")) @@ -375,7 +377,7 @@ ANN static Type tuple_depth(const Env env, const Array_Sub array) { ANN static Type partial_depth(const Env env, const Array_Sub array) { const Exp curr = take_exp(array->exp, array->type->array_depth); - if(!curr->next) + if(!curr->next || !array_base(array->type)) ERR_O(array->exp->pos, _("array subscripts (%i) exceeds defined dimension (%i)"), array->depth, get_depth(array->type)) struct Array_Sub_ next = { curr->next, array_base(array->type), array->depth - array->type->array_depth }; diff --git a/src/parse/scan1.c b/src/parse/scan1.c index f029f4c7..bf3e6bda 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -369,8 +369,7 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { if(isa(parent, t_object) < 0) ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name) if(parent->e->def && !GET_FLAG(parent, scan1)) -// CHECK_BB(scanx_parent(parent, scan1_cdef, env)) - CHECK_BB(scan1_cdef(env, parent->e->def)) + CHECK_BB(scanx_parent(parent, scan1_cdef, env)) if(type_ref(parent)) ERR_B(pos, _("can't use ref type in class extend")) return GW_OK; diff --git a/src/parse/template.c b/src/parse/template.c index 327b5c91..ace93238 100644 --- a/src/parse/template.c +++ b/src/parse/template.c @@ -163,9 +163,12 @@ ANN Type scan_tuple(const Env env, const Type_Decl *td) { do { const Type t = tl->td->xid->xid != insert_symbol("_") ? known_type(env, tl->td) : (Type)1; - if(!t) - break; - vector_add(&v, (m_uint)t); + if(t) + vector_add(&v, (m_uint)t); + else { + vector_release(&v); + return NULL; + } } while((tl = tl->next)); const Type ret = tuple_type(env, &v, td_pos(td)); vector_release(&v); diff --git a/src/parse/type_decl.c b/src/parse/type_decl.c index 49efe0be..dc1ce66e 100644 --- a/src/parse/type_decl.c +++ b/src/parse/type_decl.c @@ -28,7 +28,7 @@ ANN Type type_decl_resolve(const Env env, const Type_Decl* td) { if(t->nspc) ADD_REF(t->nspc) t->name = s_name(sym); - t->e->parent = ret; + t->flag = ret->flag; SET_FLAG(t, nonnull); map_set(&t->e->owner->info->type->map, (vtype)sym, (vtype)t); return t; -- 2.43.0