Skip to content

Commit

Permalink
Fixed caret offset for UnitRaiseNode
Browse files Browse the repository at this point in the history
  • Loading branch information
Vardan2009 committed Jun 1, 2024
1 parent da30bce commit d907080
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ def visit_UnitRaiseNode(self, node: UnitRaiseNode, context: Context) -> RTResult
assert msg_val is not None
msg = None if isinstance(msg_val, Null) else str(msg_val)

return res.failure(Error(node.pos_start, node.pos_end, errtype, msg))
start_pos = node.pos_start.copy()
start_pos.col += 1

end_pos = node.pos_end.copy()
end_pos.col += 1

return res.failure(Error(start_pos, end_pos, errtype, msg))

def visit_ImportNode(self, node: ImportNode, context: Context) -> RTResult[Value]:
res = RTResult[Value]()
Expand Down
2 changes: 1 addition & 1 deletion tests/raise3.rn.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise3.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: default massage\u001b[0m\n raise\u001b[1m\u001b[31m raise2_lib.SomeError\u001b[0m\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""}
{"code": 1, "stdout": "\u001b[38;5;208mRadiation (most recent call last):\n\u001b[0m File \u001b[38;5;117mtests/raise3.rn\u001b[0m, line \u001b[38;5;117m4\u001b[0m\n\u001b[1m\u001b[31mSomeError\u001b[0m: \u001b[38;5;203mThe massage: default massage\u001b[0m\n raise \u001b[1m\u001b[31mraise2_lib.SomeError\u001b[0m\n \u001b[1m\u001b[31m^^^^^^^^^^^^^^^^^^^^\u001b[0m\n", "stderr": ""}

0 comments on commit d907080

Please sign in to comment.