From: Jérémie Astor Date: Sun, 6 Dec 2020 18:55:27 +0000 (+0100) Subject: :art: Allow shadow in final X-Git-Tag: nightly~1121 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=a358baeb7b1e919a99eb18036945230e85045cea;p=gwion.git :art: Allow shadow in final --- diff --git a/src/parse/scan1.c b/src/parse/scan1.c index a0623547..dfc8b355 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -64,7 +64,7 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) { static inline m_bool scan1_defined(const Env env, const Var_Decl var) { if(var->value) // from a `typeof` declaration return GW_OK; - if(((!env->class_def || env->scope->depth) ? nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->xid)) + if(((!env->class_def || !GET_FLAG(env->class_def, final) || env->scope->depth) ? nspc_lookup_value1 : nspc_lookup_value2)(env->curr, var->xid)) ERR_B(var->pos, _("variable %s has already been defined in the same scope..."), s_name(var->xid)) return GW_OK; @@ -553,8 +553,10 @@ ANN static inline m_bool scan1_fdef_defined(const Env env, const Func_Def fdef) return GW_OK; if(isa(actual_type(env->gwion, v->type), env->gwion->type[et_function]) > 0) return GW_OK; - ERR_B(fdef->pos, _("function '%s' has already been defined in the same scope..."), - s_name(fdef->base->xid)) + if((!env->class_def || !GET_FLAG(env->class_def, final)) && !nspc_lookup_value0(env->curr, fdef->base->xid)) + ERR_B(fdef->pos, _("function '%s' has already been defined in the same scope..."), + s_name(fdef->base->xid)) + return GW_OK; } ANN m_bool scan1_func_def(const Env env, const Func_Def fdef) { diff --git a/tests/error/function_used.gw b/tests/error/function_used.gw index 89887f1d..4a922ffb 100644 --- a/tests/error/function_used.gw +++ b/tests/error/function_used.gw @@ -1,3 +1,3 @@ -#! [contains] has already been defined in the same scope +#! [contains] already used by another value var int i; fun void i(){}