ANN m_bool env_storage(const Env env, ae_flag flag, const loc_t pos);
ANN void env_add_type(const Env, const Type, const loc_t);
ANN Type find_type(const Env, Type_Decl *);
-ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
ANN m_bool traverse_func_template(const Env, const Func_Def);
ANN void env_err(const Env, const loc_t pos, const m_str fmt, ...);
ANN void env_warn(const Env, const loc_t pos, const m_str fmt, ...);
ANN void env_add_effect(const Env a, const Symbol effect, const loc_t pos);
ANN void call_add_effect(const Env env, const Func func, const loc_t pos);
+
+ANN m_bool already_defined(const Env env, const Symbol s, const loc_t pos);
#endif
ANN static inline void gwerr_secondary_from(const m_str msg, const ValueFrom *from) {
gwerr_secondary(msg, from->filename, from->loc);
}
+
+ANN static inline void declared_here(const Value v) {
+ gwerr_secondary_from("declared here", v->from);
+}
#endif
+
const Value v = nspc_lookup_value0(env->curr, s);
if (!v || is_class(env->gwion, v->type)) return GW_OK;
gwerr_basic(_("already declared as variable"), NULL, NULL, env->name, pos, 0);
- gwerr_secondary_from("declared here", v->from);
+ declared_here(v);
env_error_footer(env);
return GW_ERROR;
}
if(not_upvalue(env, v))
return GW_OK;
gwerr_basic(_("value not in lambda scope"), NULL, NULL, env->name, exp_self(prim)->pos, 4242);
- gwerr_secondary_from("declared here", v->from);
+ declared_here(v);
gw_err("{-}hint:{0} try adding it to capture list");
env_set_error(env, true);
return GW_ERROR;
!GET_FLAG(t->info->func->def->base, abstract) ||
!is_static_call(env->gwion, e)) return t;
env_err(env, e->pos, "making a static call to an abstract function");
- env->context->error = false;
- gwerr_secondary_from("declared here", t->info->value->from);
- env->context->error = true;
+ declared_here(t->info->value);
return NULL;
}
DECL_OO(const Type, parent, = cdef_parent(env, cdef));
if(GET_FLAG(cdef, global) && isa(parent, env->gwion->type[et_closure]) < 0 && !type_global(env, parent)) {
gwerr_basic(_("parent type is not global"), NULL, NULL, env->name, cdef->base.ext ? cdef->base.ext->pos : cdef->base.pos, 0);
- const Value v = parent->info->value;
- gwerr_warn("declared here", NULL, NULL, v->from->filename, v->from->loc);
+ declared_here(parent->info->value);
env_set_error(env, true);
return NULL;
}
const Func obase = overload->d.func_ref;
if (GET_FLAG(obase->def->base, final) && (!env->class_def || (obase->value_ref->from->owner_class != env->class_def))) {
env_err(env, f->base->pos, _("can't overload final function `{G}%s{0}`"), s_name(f->base->xid));
- env_warn(env, obase->def->base->pos, _("first declared here"));
+ declared_here(obase->value_ref);
return GW_ERROR;
}
const m_bool base = tmpl_base(f->base->tmpl);