diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-05-05 12:37:43 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-05-05 17:17:03 +0200 |
commit | 58645a78ab7c1654c513a1121511ee01551630bc (patch) | |
tree | ccd621dc905b2b48dd077480a1ec6eeb971e27d1 /src | |
parent | dd8b91eebc0d31c9f8016609b36d89f58d8c4d19 (diff) |
builtins.break: Return argument when debugging is not enabled
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/primops.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 27976dc74..1871d4b9b 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -766,32 +766,35 @@ static RegisterPrimOp primop_break({ .args = {"v"}, .doc = R"( In debug mode (enabled using `--debugger`), pause Nix expression evaluation and enter the REPL. + Otherwise, return the argument `v`. )", .fun = [](EvalState & state, const PosIdx pos, Value * * args, Value & v) { - PathSet context; - auto s = state.coerceToString(pos, *args[0], context).toOwned(); - auto error = Error(ErrorInfo{ - .level = lvlInfo, - .msg = hintfmt("breakpoint reached; value was %1%", s), - .errPos = state.positions[pos], - }); if (debuggerHook && !state.debugTraces.empty()) { + PathSet context; + auto s = state.coerceToString(pos, *args[0], context).toOwned(); + + auto error = Error(ErrorInfo { + .level = lvlInfo, + .msg = hintfmt("breakpoint reached; value was %1%", s), + .errPos = state.positions[pos], + }); + auto & dt = state.debugTraces.front(); debuggerHook(&error, dt.env, dt.expr); if (state.debugQuit) { - // if the user elects to quit the repl, throw an exception. + // If the user elects to quit the repl, throw an exception. throw Error(ErrorInfo{ .level = lvlInfo, .msg = hintfmt("quit the debugger"), .errPos = state.positions[noPos], }); } - - // returning the value we were passed. - v = *args[0]; } + + // Return the value we were passed. + v = *args[0]; } }); |