Skip to content

Commit b231fb7

Browse files
Update ops.py
1 parent 7cdb1be commit b231fb7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mypyc/ir/ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,9 +1051,9 @@ def __init__(self, src: Value, index: int, line: int = -1, *, borrow: bool = Fal
10511051
src.type, RTuple
10521052
), "TupleGet only operates on tuples, not {type(src.type).__name__}"
10531053
src_len = len(src.type.types)
1054-
assert (
1055-
-src_len <= index <= src_len - 1
1056-
), f"Index out of range.\nsource type: {src.type}\nindex: {index}"
1054+
if index < 0:
1055+
index += src_len
1056+
assert index <= src_len - 1, f"Index out of range.\nsource type: {src.type}\nindex: {index}"
10571057
self.type = src.type.types[index]
10581058
self.is_borrowed = borrow
10591059

0 commit comments

Comments
 (0)