ANN2(1, 3) ANEW Context new_context(MemPool p, const Ast, const m_str);
ANN void load_context(const Context, const Env);
ANN void unload_context(const Context, const Env);
+
+ANN static inline void env_set_error(const Env env) {
+ if(env->context) env->context->error = true;
+}
#endif
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 bool check_effect_overload(const Vector base, const Func override);
+
#endif
env_xxx(env, pos, fmt, arg);
va_end(arg);
#endif
- if (env->context) env->context->error = 1;
+ env_set_error(env);
}
ANN struct SpecialId_ *specialid_get(const Gwion gwion, const Symbol sym) {
if (base->size == 0) {
gwerr_basic("Can't use type of size 0 as array base", NULL, NULL,
"/dev/null", (loc_t) {}, 0);
- env->context->error = true;
+ env_set_error(env);
return env->gwion->type[et_error];
}
if (!strncmp(base->name, "Ref:[", 5)) {
gwerr_basic("Can't use ref types as array base", NULL, NULL, "/dev/null",
(loc_t) {}, 0);
- env->context->error = true;
+ env_set_error(env);
return env->gwion->type[et_error];
}
if (!strncmp(base->name, "Option:[", 5)) {
gwerr_basic("Can't use option types as array base", NULL, NULL, "/dev/null",
(loc_t) {}, 0);
- env->context->error = true;
+ env_set_error(env);
return env->gwion->type[et_error];
}
const Symbol sym = array_sym(env, array_base(base), base->array_depth + 1);
_("Decayed operators take two arguments"), NULL, env->name, loc,
0);
if (fdef) defined_here(fdef->base->func->value_ref);
- env->context->error = true;
+ env_set_error(env);
}
}
static m_bool op_call_narg(const Env env, Exp arg, const loc_t loc) {
exp_self(member)->pos, 0);
env_error_footer(env);
defined_here(value);
- env->context->error = true;
+ env_set_error(env);
} else if (GET_FLAG(value, protect))
exp_setprot(exp_self(member), 1);
}
if (prim_array_inner(env, type, e, loc) < 0) err = true;
while ((e = e->next));
if (!err) return array_type(env, array_base(type), type->array_depth + 1);
- env->context->error = true;
+ env_set_error(env);
return NULL;
}
gwerr_basic(_("Invalid variable"), _("not legit at this point."), NULL,
env->name, prim_pos(data), 0);
did_you_mean_nspc(v ? value_owner(env, v) : env->curr, s_name(sym));
- env->context->error = true;
+ env_set_error(env);
return NULL;
}
prim_self(data)->value = v;
prim_exp(data)->type = t;
return t;
}
- env->context->error = true;
+ env_set_error(env);
return NULL;
}
*/
print_current_args(args);
else
gw_err(_("and not:\n {G}void{0}\n"));
- if (env->context) env->context->error = true;
+ env_set_error(env);
}
ANN static m_uint get_type_number(Specialized_List list) {
char from[strlen(tdef->type->name) + 39];
sprintf(from, "in `{/+}%s{0}` definition", tdef->type->name);
gwerr_secondary(from, env->name, tdef->pos);
- if (env->context) env->context->error = true;
+ env_set_error(env);
return GW_ERROR;
}
/*
gwerr_basic(_("invalid repeat condition type"), explain,
_("use an integer or cast to int if possible"), env->name,
e->pos, 0);
- env->context->error = true;
+ env_set_error(env);
return GW_ERROR;
}
return GW_OK;
}
struct ValueFrom_ *from = f->value_ref->from;
gwerr_secondary("implementation missing", from->filename, from->loc);
- env->context->error = true;
+ env_set_error(env);
}
}
return !err ? GW_OK : GW_ERROR;
if (value_error) {
env->class_def = t;
env_error_footer(env);
- env->context->error = true;
+ env_set_error(env);
return GW_ERROR;
}
}
env_err(env, v->from->loc, _("recursive type"));
env->context->error = false;
env_err(env, value->from->loc, _("recursive type"));
- env->context->error = true;
+ env_set_error(env);
type_remref(t, env->gwion);
return GW_ERROR;
}
const Trait trait = nspc_lookup_trait1(env->curr, list->xid);
if (!trait_nodup(t, list->xid, list->next)) {
gwerr_secondary("duplicated trait", trait->filename, trait->loc);
+ env_set_error(env);
return false;
}
const bool value_error = trait->requested_values.ptr ? check_trait_variables(env, t, trait) : false;
if (!value_error && !funcs_error) return true;
const Value request = (Value)vector_front(&trait->requested_values);
gwerr_secondary("from trait", request->from->filename, trait->loc);
+ env_set_error(env);
return false;
}
if (!nspc_lookup_trait1(env->curr, traits->xid)) {
gwerr_basic(_("can't find trait"), NULL, NULL, env->name, pos, 0);
did_you_mean_trait(env->curr, s_name(traits->xid));
- env->context->error = true;
+ env_set_error(env);
return GW_ERROR;
}
} while ((traits = traits->next));
if (exists) {
gwerr_basic("trait already defined", NULL, NULL, env->name, pdef->pos, 0);
gwerr_secondary("defined here", env->name, exists->loc);
- env->context->error = true;
+ env_set_error(env);
return already_defined(env, s, pdef->pos);
}
if (pdef->traits) CHECK_BB(find_traits(env, pdef->traits, pdef->pos));
gwerr_secondary("not declared global", from->filename, from->loc);
const struct ValueFrom_ *ownerFrom = env->class_def->info->value->from;
gwerr_secondary("is global", ownerFrom->filename, ownerFrom->loc);
+ env_set_error(env);
return false;
}
return true;
gwerr_basic(_("shadowing a previously defined variable"), NULL, NULL,
env->name, loc, 0);
defined_here(v);
- env->context->error = true;
+ env_set_error(env);
return GW_ERROR;
}