Skip to content

Commit 2be7229

Browse files
committed
feat: handle RTuple type
1 parent 96513e7 commit 2be7229

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

mypyc/irbuild/ll_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,12 @@ def _construct_varargs(
799799
# fn(*args)
800800
if is_list_rprimitive(value.type):
801801
value = self.primitive_op(list_tuple_op, [value], line)
802-
elif not is_tuple_rprimitive(value.type):
802+
elif not is_tuple_rprimitive(value.type) and not isinstance(value.type, RTuple):
803803
value = self.primitive_op(sequence_tuple_op, [value], line)
804804
return value, self._create_dict([], [], line)
805805
elif len(args) == 2 and args[1][1] == ARG_STAR2:
806806
# fn(*args, **kwargs)
807-
if is_tuple_rprimitive(value.type):
807+
if is_tuple_rprimitive(value.type) or isinstance(value.type, RTuple):
808808
star_result = value
809809
elif is_list_rprimitive(value.type):
810810
star_result = self.primitive_op(list_tuple_op, [value], line)

mypyc/test-data/irbuild-basic.test

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,22 +1674,20 @@ def g():
16741674
r0 :: tuple[int, int, int]
16751675
r1 :: dict
16761676
r2 :: str
1677-
r3, r4 :: object
1678-
r5 :: tuple
1679-
r6 :: dict
1680-
r7 :: object
1681-
r8 :: tuple[int, int, int]
1677+
r3 :: object
1678+
r4 :: dict
1679+
r5, r6 :: object
1680+
r7 :: tuple[int, int, int]
16821681
L0:
16831682
r0 = (2, 4, 6)
16841683
r1 = __main__.globals :: static
16851684
r2 = 'f'
16861685
r3 = CPyDict_GetItem(r1, r2)
1687-
r4 = box(tuple[int, int, int], r0)
1688-
r5 = PySequence_Tuple(r4)
1689-
r6 = PyDict_New()
1690-
r7 = PyObject_Call(r3, r5, r6)
1691-
r8 = unbox(tuple[int, int, int], r7)
1692-
return r8
1686+
r4 = PyDict_New()
1687+
r5 = box(tuple[int, int, int], r0)
1688+
r6 = PyObject_Call(r3, r5, r4)
1689+
r7 = unbox(tuple[int, int, int], r6)
1690+
return r7
16931691
def h():
16941692
r0 :: tuple[int, int]
16951693
r1 :: dict

0 commit comments

Comments
 (0)