fix remaining fixtures

This commit is contained in:
Guillaume Maudoux 2022-09-11 22:58:59 +02:00
parent c7b901fd33
commit e412bb6d30

View file

@ -1389,11 +1389,10 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
std::set<std::string> allAttrNames; std::set<std::string> allAttrNames;
for (auto & attr : *vAttrs->attrs) for (auto & attr : *vAttrs->attrs)
allAttrNames.insert(state.symbols[attr.name]); allAttrNames.insert(state.symbols[attr.name]);
throw EvalError("foo"); auto suggestions = Suggestions::bestMatches(allAttrNames, state.symbols[name]);
//tmp: state.throwEvalError( state.throwError<EvalError>(pos, "attribute '%1%' missing",
// pos, "", "", &name, 0, 0, 0, noPos, "", &suggestions,
// Suggestions::bestMatches(allAttrNames, state.symbols[name]), &env, this);
// "attribute '%1%' missing", state.symbols[name], env, *this);
} }
} }
vAttrs = j->value; vAttrs = j->value;
@ -1503,13 +1502,10 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
auto j = args[0]->attrs->get(i.name); auto j = args[0]->attrs->get(i.name);
if (!j) { if (!j) {
if (!i.def) { if (!i.def) {
throw EvalError("foo"); throwErrorWithTrace<TypeError>(lambda.pos,
/*
throwTypeErrorWithTrace(lambda.pos,
"function '%1%' called without required argument '%2%'", "function '%1%' called without required argument '%2%'",
(lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"), (lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"), "",
i.name, pos, "from call site", *fun.lambda.env, lambda); &i.name, 0, 0, 0, noPos, "", 0, pos, "from call site", fun.lambda.env, &lambda);
*/
} }
env2.values[displ++] = i.def->maybeThunk(*this, env2); env2.values[displ++] = i.def->maybeThunk(*this, env2);
} else { } else {
@ -1528,14 +1524,11 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
std::set<std::string> formalNames; std::set<std::string> formalNames;
for (auto & formal : lambda.formals->formals) for (auto & formal : lambda.formals->formals)
formalNames.insert(symbols[formal.name]); formalNames.insert(symbols[formal.name]);
throw EvalError("foo"); auto suggestions = Suggestions::bestMatches(formalNames, symbols[i.name]);
/* throwErrorWithTrace<TypeError>(lambda.pos,
throwTypeErrorWithTrace(lambda.pos,
Suggestions::bestMatches(formalNames, symbols[i.name]),
"function '%1%' called with unexpected argument '%2%'", "function '%1%' called with unexpected argument '%2%'",
(lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"), (lambda.name ? std::string(symbols[lambda.name]) : "anonymous lambda"), "",
i.name, pos, "from call site"); &i.name, 0, 0, 0, noPos, "", &suggestions, pos, "from call site", fun.lambda.env, &lambda);
*/
} }
abort(); // can't happen abort(); // can't happen
} }
@ -1763,7 +1756,7 @@ void ExprAssert::eval(EvalState & state, Env & env, Value & v)
if (!state.evalBool(env, cond, pos, "in the condition of the assert statement")) { if (!state.evalBool(env, cond, pos, "in the condition of the assert statement")) {
std::ostringstream out; std::ostringstream out;
cond->show(state.symbols, out); cond->show(state.symbols, out);
//tmp: state.throwAssertionError(pos, "assertion '%1%' failed", out.str(), env, *this); state.throwError<AssertionError>(pos, "assertion '%1%' failed", out.str(), "", 0, 0, 0, 0, noPos, "", 0, &env, this);
} }
body->eval(state, env, v); body->eval(state, env, v);
} }