Skip to content

Commit 85da4d5

Browse files
committed
Add test for propagation of symbols through tuples
1 parent 50803e7 commit 85da4d5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,25 @@ def f(l: complex, r: complex) -> None:
15551555
with self.subTest(l=l, r=r, x=x, y=y):
15561556
script_helper.assert_python_ok("-c", s)
15571557

1558+
def test_symbols_flow_through_tuples(self):
1559+
def testfunc(n):
1560+
for _ in range(n):
1561+
a = 1
1562+
b = 2
1563+
t = a, b
1564+
x, y = t
1565+
r = x + y
1566+
return r
1567+
1568+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1569+
self.assertEqual(res, 3)
1570+
self.assertIsNotNone(ex)
1571+
uops = get_opnames(ex)
1572+
self.assertIn("_BINARY_OP_ADD_INT", uops)
1573+
self.assertNotIn("_GUARD_BOTH_INT", uops)
1574+
self.assertNotIn("_GUARD_NOS_INT", uops)
1575+
self.assertNotIn("_GUARD_TOS_INT", uops)
1576+
15581577
def test_decref_escapes(self):
15591578
class Convert9999ToNone:
15601579
def __del__(self):

0 commit comments

Comments
 (0)