member->base->d.prim.prim_type != ae_prim_id ||
strcmp(s_name(member->base->d.prim.d.var), "this"))
ERR_N(exp_self(member)->pos, "calling a parent constructor is only allowed with `this`");
+ if(GET_FLAG(env->func, const))
+ ERR_N(exp_self(member)->pos, "parent constructor already called");
SET_FLAG(env->func, const); // mark the function as ctor_ok
const Value ret = nspc_lookup_value1(parent->nspc, sym);
member->xid = sym;
return ret;
}
-ANN m_bool check_new(const Env env, const Func_Def fdef) {
- if(!fdef->builtin && !GET_FLAG(fdef->base->func, const) &&
- GET_FLAG(env->class_def->info->parent, abstract)) {
- // we can probably do simpler, but this may require fixing new@ index
- const Value v = nspc_lookup_value0(env->class_def->info->parent->nspc, fdef->base->xid);
- if(v) {
- Func f = v->d.func_ref;
- while(f) {
- if(compat_func(fdef, f->def)) break;
- f = f->next;
- }
- if(f && GET_FLAG(f, abstract)) ERR_B(fdef->base->pos, "What what?");
- }
- }
- return GW_OK;
-}
-
ANN m_bool check_func_def(const Env env, const Func_Def fdef) {
const uint16_t depth = env->scope->depth;
env->scope->depth = 0;
const m_bool ret = _check_func_def(env, fdef);
env->scope->depth = depth;
- // we need to find matching parent and see if abstract
- if(!strcmp(s_name(fdef->base->xid), "new"))
- CHECK_BB(check_new(env, fdef));
return ret;
}