From e3b797d550c2313b754b63640a5d9c7990206dda Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 8 Dec 2022 14:33:37 +0100 Subject: [PATCH] :art: proper constructor checking wrt super --- src/parse/check.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/parse/check.c b/src/parse/check.c index fe356397..d6844c69 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1817,10 +1817,17 @@ ANN m_bool check_fdef(const Env env, const Func_Def fdef) { ANN static m_bool check_ctor(const Env env, const Func func) { if(!func->def->builtin && !GET_FLAG(func, const)) { - const Value v = nspc_lookup_value0(env->class_def->info->parent->nspc, insert_symbol("new")); - if(v && !GET_FLAG(v, abstract)) - ERR_B(func->def->base->pos, "missing call to parent constructor"); + const Type_Decl *td = env->class_def->info->cdef->base.ext; + const m_uint depth = !td || !td->array + ? 1 : td->array->exp->d.prim.d.num; + if(depth) { // check if size is 0 + const Type parent = env->class_def->info->parent; + const Value v = nspc_lookup_value0(parent->nspc, insert_symbol("new")); + if(v && !GET_FLAG(v->d.func_ref->def->base, abstract)) + ERR_B(func->def->base->pos, "missing call to parent constructor"); + } } + return GW_OK; } -- 2.43.0