From 5d9087566da5588bbacbae0aed24bebd4e0d8969 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 18 Apr 2022 18:35:52 +0200 Subject: [PATCH] :art: Better define primitive --- src/parse/scan0.c | 3 +++ src/parse/scan1.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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")) -- 2.43.0