mirror of
https://github.com/NixOS/nix
synced 2025-06-28 17:51:15 +02:00
optinoal error; compiles
This commit is contained in:
parent
c51b527c28
commit
a963674d88
5 changed files with 42 additions and 37 deletions
|
@ -63,7 +63,7 @@ EvalCommand::EvalCommand()
|
|||
});
|
||||
}
|
||||
|
||||
extern std::function<void(const Error & error, const Env & env, const Expr & expr)> debuggerHook;
|
||||
extern std::function<void(const Error * error, const Env & env, const Expr & expr)> debuggerHook;
|
||||
|
||||
ref<EvalState> EvalCommand::getEvalState()
|
||||
{
|
||||
|
@ -76,13 +76,14 @@ ref<EvalState> EvalCommand::getEvalState()
|
|||
#endif
|
||||
searchPath, getEvalStore(), getStore());
|
||||
if (startReplOnEvalErrors)
|
||||
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error & error, const Env & env, const Expr & expr) {
|
||||
printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error.what());
|
||||
debuggerHook = [evalState{ref<EvalState>(evalState)}](const Error * error, const Env & env, const Expr & expr) {
|
||||
if (error)
|
||||
printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error->what());
|
||||
|
||||
if (expr.staticenv)
|
||||
{
|
||||
auto vm = mapStaticEnvBindings(*expr.staticenv.get(), env);
|
||||
runRepl(evalState, &error, expr, *vm);
|
||||
runRepl(evalState, error, expr, *vm);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -917,19 +917,23 @@ void runRepl(
|
|||
{
|
||||
auto repl = std::make_unique<NixRepl>(evalState);
|
||||
|
||||
repl->debugError = debugError;
|
||||
// repl->debugError = debugError;
|
||||
|
||||
repl->initEnv();
|
||||
|
||||
// tack on a final DebugTrace for the error position.
|
||||
DebugTraceStacker ldts(
|
||||
*evalState,
|
||||
DebugTrace
|
||||
{.pos = debugError->info().errPos,
|
||||
.expr = expr,
|
||||
.env = *repl->env,
|
||||
.hint = debugError->info().msg
|
||||
});
|
||||
// auto dts = debugError ?
|
||||
// std::unique_ptr<DebugTraceStacker>(
|
||||
// // tack on a final DebugTrace for the error position.
|
||||
// new DebugTraceStacker(
|
||||
// *evalState,
|
||||
// DebugTrace
|
||||
// {.pos = debugError->info().errPos,
|
||||
// .expr = expr,
|
||||
// .env = *repl->env,
|
||||
// .hint = debugError->info().msg
|
||||
// })
|
||||
// )
|
||||
// : nullptr;
|
||||
|
||||
// add 'extra' vars.
|
||||
std::set<std::string> names;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue