forked from lix-project/lix
builtins.break: Return argument when debugging is not enabled
This commit is contained in:
parent
dd8b91eebc
commit
58645a78ab
|
@ -766,32 +766,35 @@ static RegisterPrimOp primop_break({
|
||||||
.args = {"v"},
|
.args = {"v"},
|
||||||
.doc = R"(
|
.doc = R"(
|
||||||
In debug mode (enabled using `--debugger`), pause Nix expression evaluation and enter the REPL.
|
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)
|
.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()) {
|
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();
|
auto & dt = state.debugTraces.front();
|
||||||
debuggerHook(&error, dt.env, dt.expr);
|
debuggerHook(&error, dt.env, dt.expr);
|
||||||
|
|
||||||
if (state.debugQuit) {
|
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{
|
throw Error(ErrorInfo{
|
||||||
.level = lvlInfo,
|
.level = lvlInfo,
|
||||||
.msg = hintfmt("quit the debugger"),
|
.msg = hintfmt("quit the debugger"),
|
||||||
.errPos = state.positions[noPos],
|
.errPos = state.positions[noPos],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// returning the value we were passed.
|
|
||||||
v = *args[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the value we were passed.
|
||||||
|
v = *args[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue