#define NSPC(a) { nspc_push_value(env->curr); SCOPE(a); nspc_pop_value(env->curr); }
struct Env_Scope_ {
- struct Vector_ nspc_stack;
- struct Vector_ class_stack;
- struct Vector_ breaks;
- struct Vector_ conts;
- struct Vector_ known_ctx;
- struct Match_ *match;
+ struct Vector_ nspc_stack;
+ struct Vector_ class_stack;
+ struct Vector_ breaks;
+ struct Vector_ conts;
+ struct Vector_ known_ctx;
+ struct Match_ *match;
size_t depth;
};
-typedef struct Env_ * Env;
-struct Env_ {
+typedef struct Env_ {
m_str name;
Nspc curr;
Nspc global_nspc;
Func func;
struct Gwion_ *gwion;
struct Env_Scope_* scope;
-};
+} *Env;
ANEW Env new_env(MemPool);
ANN void env_reset(const Env);
const Symbol sym = *data;
const Value v = check_non_res_value(env, data);
if(!v || !vflag(v, vflag_valid) || (v->from->ctx && v->from->ctx->error)) {
- gwerr_basic(_("Invalid variable"), _("not legit at this point."), "did you mean:",
+ 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++;
return (i && j && d[m-1][n-1] < MAX_DISTANCE);
}
-ANN static void ressembles(const Vector v, const Nspc nspc, const char* name) {
+ANN static void ressembles(const Vector v, const Nspc nspc, const char* name, bool *const done) {
struct scope_iter iter = { nspc->info->value, 0, 0 };
Value value;
while(scope_iter(&iter, &value) > 0) {
if(vector_find(v, (vtype)value->name) > 0 &&!strcmp(name, value->name))
continue;
if(wagner_fisher(name, value->name)) {
+ if(!*done) {
+ *done = true;
+ gw_err("{-/}did you mean{0}:");
+ }
if(!vflag(value, vflag_builtin))
gwerr_secondary("declared here", value->from->filename, value->from->loc);
}
CHECK_LEN(name)
struct Vector_ v;
vector_init(&v);
- do ressembles(&v, nspc, name);
+ bool done;
+ do ressembles(&v, nspc, name, &done);
while((nspc = nspc->parent));
vector_release(&v);
}
Type t = type;
struct Vector_ v;
vector_init(&v);
- do ressembles(&v, t->nspc, name);
+ bool done;
+ do ressembles(&v, t->nspc, name, &done);
while((t = t->info->parent) && t->nspc);
vector_release(&v);
}