aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/repl.cc
diff options
context:
space:
mode:
authorBen Burdette <bburdette@protonmail.com>2022-04-06 19:08:29 -0600
committerBen Burdette <bburdette@protonmail.com>2022-04-06 19:08:29 -0600
commit5cfd038bd8bcd65c45f08f6c3665cd49e6643714 (patch)
tree217d909a97cfec7d8d44928e5123fab006e10c2d /src/libcmd/repl.cc
parentf41c18b2210ac36743f03ea218860b7941f4264e (diff)
show expr pos if DebugTrace one is noPos
Diffstat (limited to 'src/libcmd/repl.cc')
-rw-r--r--src/libcmd/repl.cc8
1 files changed, 5 insertions, 3 deletions
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);