diff options
author | Ben Burdette <bburdette@protonmail.com> | 2022-02-14 14:04:34 -0700 |
---|---|---|
committer | Ben Burdette <bburdette@protonmail.com> | 2022-02-14 14:04:34 -0700 |
commit | e761bf0601a56db26c31891a3433c1319814fffa (patch) | |
tree | c750c81b0d3db455ec658687772e35005221cdcf | |
parent | 4cffb130e385bc3f4c5ca0482ad8c4dd22229cfe (diff) |
make an 'info' level error on break
-rw-r--r-- | src/libcmd/repl.cc | 16 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 15 |
2 files changed, 8 insertions, 23 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 51bbbbc57..db88aa9b6 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -931,24 +931,10 @@ void runRepl( { auto repl = std::make_unique<NixRepl>(evalState); - // repl->debugError = debugError; + repl->debugError = debugError; repl->initEnv(); - // 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; for (auto & [name, value] : extraEnv) { diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 956c55e49..25845bdc4 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -699,6 +699,7 @@ static RegisterPrimOp primop_genericClosure(RegisterPrimOp::Info { .fun = prim_genericClosure, }); + static RegisterPrimOp primop_break({ .name = "break", .args = {"v"}, @@ -707,17 +708,15 @@ static RegisterPrimOp primop_break({ )", .fun = [](EvalState & state, const Pos & pos, Value * * args, Value & v) { - std::cout << "primop_break, value: " << *args[0] << std::endl; - // PathSet context; - // string s = state.coerceToString(pos, *args[0], context); + auto error = Error(ErrorInfo{ + .level = lvlInfo, + .msg = hintfmt("breakpoint reached; value was %1%", *args[0]), + .errPos = pos, + }); if (debuggerHook && !state.debugTraces.empty()) { auto &dt = state.debugTraces.front(); - // std::optional<ErrPos> pos; - // const Expr &expr; - // const Env &env; - // hintformat hint; - debuggerHook(nullptr, dt.env, dt.expr); + debuggerHook(&error, dt.env, dt.expr); // returning the value we were passed. v = *args[0]; |