more readable syntax error construction

This commit is contained in:
Bob Polis 2020-09-22 13:41:23 +02:00
parent 0e735ce7a8
commit 7a6f9df82f

View File

@ -129,7 +129,8 @@ void interpreter::exec_instruction(const std::string& code, bool& done) {
else if (code == "err") err(); else if (code == "err") err();
else { else {
auto it = std::upper_bound(_pc_offsets.begin(), _pc_offsets.end(), _pc); 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}; throw syntax_error {code, lineno};
} }
} }