Skip to content

Commit 115df84

Browse files
authored
gh-104635: Add a test case for variables that have a dependency. (gh-106583)
1 parent 22988c3 commit 115df84

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Lib/test/test_compile.py

+9
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,15 @@ def f(x, y, z):
11861186
return a
11871187
self.assertEqual(f("x", "y", "z"), "y")
11881188

1189+
def test_variable_dependent(self):
1190+
# gh-104635: Since the value of b is dependent on the value of a
1191+
# the first STORE_FAST for a should not be skipped. (e.g POP_TOP).
1192+
# This test case is added to prevent potential regression from aggressive optimization.
1193+
def f():
1194+
a = 42; b = a + 54; a = 54
1195+
return a, b
1196+
self.assertEqual(f(), (54, 96))
1197+
11891198

11901199
@requires_debug_ranges()
11911200
class TestSourcePositions(unittest.TestCase):

0 commit comments

Comments
 (0)