aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/command.cc2
-rw-r--r--src/libcmd/repl.cc8
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc
index 34535802f..cc353cbb4 100644
--- a/src/libcmd/command.cc
+++ b/src/libcmd/command.cc
@@ -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,
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 5de4cdf76..416635f16 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -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);