From: Jérémie Astor Date: Mon, 18 Apr 2022 16:35:52 +0000 (+0200) Subject: :art: Better define primitive X-Git-Tag: nightly~298 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=5d9087566da5588bbacbae0aed24bebd4e0d8969;p=gwion.git :art: Better define primitive --- diff --git a/src/parse/scan0.c b/src/parse/scan0.c index 99feeb47..72609356 100644 --- a/src/parse/scan0.c +++ b/src/parse/scan0.c @@ -150,10 +150,13 @@ ANN static m_bool typedef_complex(const Env env, const Type_Def tdef, const Class_Def cdef = new_class_def(env->gwion->mp, flag, tdef->xid, cpy_type_decl(env->gwion->mp, tdef->ext), NULL, tdef->ext->pos); + const bool final = GET_FLAG(base, final); + if(final) UNSET_FLAG(base, final); CHECK_BB(scan0_class_def(env, cdef)); tdef->type = cdef->base.type; cdef->base.tmpl = tdef->tmpl; // check cpy set_tflag(tdef->type, tflag_cdef); + if(final) SET_FLAG(base, final); mk_class(env, tdef->type, tdef->pos); return GW_OK; } diff --git a/src/parse/scan1.c b/src/parse/scan1.c index 2a31cf94..c9e6783a 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -725,7 +725,8 @@ ANN static m_bool scan1_parent(const Env env, const Class_Def cdef) { if (cdef->base.ext->array && cdef->base.ext->array->exp) CHECK_BB(scan1_exp(env, cdef->base.ext->array->exp)); DECL_OB(const Type, parent, = scan1_get_parent(env, &cdef->base)); - if (isa(parent, env->gwion->type[et_object]) < 0) + if (isa(parent, env->gwion->type[et_object]) < 0 && + !(tflag(cdef->base.type, tflag_cdef) || tflag(cdef->base.type, tflag_udef))) ERR_B(pos, _("cannot extend primitive type '%s'"), parent->name) CHECK_BB(ensure_scan1(env, parent)); if (type_ref(parent)) ERR_B(pos, _("can't use ref type in class extend"))