From e761bf0601a56db26c31891a3433c1319814fffa Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 14 Feb 2022 14:04:34 -0700 Subject: [PATCH] make an 'info' level error on break --- src/libcmd/repl.cc | 16 +--------------- 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(evalState); - // repl->debugError = debugError; + repl->debugError = debugError; repl->initEnv(); - // auto dts = debugError ? - // std::unique_ptr( - // // 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 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 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];