mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
Enter debugger more reliably in let expressions and calls
This commit is contained in:
parent
081dc5daa1
commit
0127d54d5e
1 changed files with 28 additions and 3 deletions
|
@ -846,20 +846,20 @@ void EvalState::addErrorTrace(Error & e, const PosIdx pos, const char * s, const
|
||||||
e.addTrace(positions[pos], hintfmt(s, s2), frame);
|
e.addTrace(positions[pos], hintfmt(s, s2), frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
static std::unique_ptr<DebugTraceStacker> makeDebugTraceStacker(
|
static std::unique_ptr<DebugTraceStacker> makeDebugTraceStacker(
|
||||||
EvalState & state,
|
EvalState & state,
|
||||||
Expr & expr,
|
Expr & expr,
|
||||||
Env & env,
|
Env & env,
|
||||||
std::shared_ptr<Pos> && pos,
|
std::shared_ptr<Pos> && pos,
|
||||||
const char * s,
|
const Args & ... formatArgs)
|
||||||
const std::string & s2)
|
|
||||||
{
|
{
|
||||||
return std::make_unique<DebugTraceStacker>(state,
|
return std::make_unique<DebugTraceStacker>(state,
|
||||||
DebugTrace {
|
DebugTrace {
|
||||||
.pos = std::move(pos),
|
.pos = std::move(pos),
|
||||||
.expr = expr,
|
.expr = expr,
|
||||||
.env = env,
|
.env = env,
|
||||||
.hint = hintfmt(s, s2),
|
.hint = hintfmt(formatArgs...),
|
||||||
.isError = false
|
.isError = false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1322,6 +1322,19 @@ void ExprLet::eval(EvalState & state, Env & env, Value & v)
|
||||||
for (auto & i : attrs->attrs)
|
for (auto & i : attrs->attrs)
|
||||||
env2.values[displ++] = i.second.e->maybeThunk(state, i.second.inherited ? env : env2);
|
env2.values[displ++] = i.second.e->maybeThunk(state, i.second.inherited ? env : env2);
|
||||||
|
|
||||||
|
auto dts = state.debugRepl
|
||||||
|
? makeDebugTraceStacker(
|
||||||
|
state,
|
||||||
|
*this,
|
||||||
|
env2,
|
||||||
|
getPos()
|
||||||
|
? std::make_shared<Pos>(state.positions[getPos()])
|
||||||
|
: nullptr,
|
||||||
|
"while evaluating a '%1%' expression",
|
||||||
|
"let"
|
||||||
|
)
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
body->eval(state, env2, v);
|
body->eval(state, env2, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,6 +1731,18 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
|
||||||
|
|
||||||
void ExprCall::eval(EvalState & state, Env & env, Value & v)
|
void ExprCall::eval(EvalState & state, Env & env, Value & v)
|
||||||
{
|
{
|
||||||
|
auto dts = state.debugRepl
|
||||||
|
? makeDebugTraceStacker(
|
||||||
|
state,
|
||||||
|
*this,
|
||||||
|
env,
|
||||||
|
getPos()
|
||||||
|
? std::make_shared<Pos>(state.positions[getPos()])
|
||||||
|
: nullptr,
|
||||||
|
"while calling a function"
|
||||||
|
)
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
Value vFun;
|
Value vFun;
|
||||||
fun->eval(state, env, vFun);
|
fun->eval(state, env, vFun);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue