From 7a6f9df82f7acf7e180fca548bb629148c90ed57 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 22 Sep 2020 13:41:23 +0200 Subject: [PATCH] more readable syntax error construction --- interpreter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interpreter.cpp b/interpreter.cpp index 632f492..285f515 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -129,7 +129,8 @@ void interpreter::exec_instruction(const std::string& code, bool& done) { else if (code == "err") err(); else { auto it = std::upper_bound(_pc_offsets.begin(), _pc_offsets.end(), _pc); - size_t lineno {it - _pc_offsets.begin() + _pc + 1}; + long num_removed_source_lines {it - _pc_offsets.begin()}; + size_t lineno {num_removed_source_lines + _pc + 1}; throw syntax_error {code, lineno}; } }