forked from lix-project/lix
show expr pos if DebugTrace one is noPos
This commit is contained in:
parent
f41c18b221
commit
5cfd038bd8
|
@ -129,7 +129,7 @@ ref<EvalState> EvalCommand::getEvalState()
|
|||
new DebugTraceStacker(
|
||||
*evalState,
|
||||
DebugTrace
|
||||
{.pos = *expr.getPos(),
|
||||
{.pos = (error->info().errPos ? *error->info().errPos : *expr.getPos()),
|
||||
.expr = expr,
|
||||
.env = env,
|
||||
.hint = error->info().msg,
|
||||
|
|
|
@ -412,9 +412,11 @@ std::ostream& showDebugTrace(std::ostream &out, const DebugTrace &dt)
|
|||
out << ANSI_RED "error: " << ANSI_NORMAL;
|
||||
out << dt.hint.str() << "\n";
|
||||
|
||||
if (dt.pos.has_value() && (*dt.pos)) {
|
||||
auto pos = dt.pos.value();
|
||||
out << "\n";
|
||||
// prefer direct pos, but if noPos then try the expr.
|
||||
auto pos = (*dt.pos ? *dt.pos :
|
||||
(dt.expr.getPos() ? *dt.expr.getPos() : noPos));
|
||||
|
||||
if (pos) {
|
||||
printAtPos(pos, out);
|
||||
|
||||
auto loc = getCodeLines(pos);
|
||||
|
|
Loading…
Reference in a new issue