From: fennecdjay Date: Sun, 9 Jun 2019 19:41:13 +0000 (+0200) Subject: :art: Fixes #119 X-Git-Tag: nightly~2443^2~2 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3bac2e7a22d38251947a33108457c32d34672c0d;p=gwion.git :art: Fixes #119 --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 259553c7..644a8546 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1688,6 +1688,7 @@ ANN static void emit_func_def_code(const Emitter emit, const Func func) { ADD_REF(func->code) } // TODO: find why we need this + assert(func->def->stack_depth == func->code->stack_depth); func->def->stack_depth = func->code->stack_depth; } diff --git a/src/parse/scan2.c b/src/parse/scan2.c index b9a4e5dc..02af3dbf 100644 --- a/src/parse/scan2.c +++ b/src/parse/scan2.c @@ -480,10 +480,6 @@ ANN2(1,2,4) /*static */Value func_create(const Env env, const Func_Def f, scan2_func_def_flag(env, f); if(GET_FLAG(f, builtin)) CHECK_BO(scan2_func_def_builtin(env->gwion->mp, func, func->name)) - if(GET_FLAG(func, member)) - f->stack_depth += SZ_INT; - if(GET_FLAG(func->def, variadic)) - f->stack_depth += SZ_INT; nspc_add_value(env->curr, insert_symbol(func->name), v); return v; } @@ -495,10 +491,6 @@ ANN static m_str template_helper(const Env env, const Func_Def f) { return(m_str)GW_ERROR; const Func func = nspc_lookup_func1(env->curr, insert_symbol(name)); if(func) { - if(GET_FLAG(func, member)) - f->stack_depth += SZ_INT; - if(GET_FLAG(func->def, variadic)) - f->stack_depth += SZ_INT; f->base->ret_type = known_type(env, f->base->td); return (m_str)(m_uint)((f->base->args && f->base->args->type) ? scan2_args(env, f) : GW_OK); } @@ -519,7 +511,9 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { const Value res = nspc_lookup_value1(env->global_nspc, f->base->xid); if(res) ERR_B(f->pos, "'%s' already declared as type", s_name(f->base->xid)) - f->stack_depth = 0; + f->stack_depth = (env->class_def && !GET_FLAG(f, static) && !GET_FLAG(f, global)) ? SZ_INT : 0; + if(GET_FLAG(f, variadic)) + f->stack_depth += SZ_INT; if(overload) CHECK_BB(scan2_func_def_overload(env, f, overload)) if(tmpl_base(f->base->tmpl))