Skip to content

Commit

Permalink
gh-104635: Add a test case for variables that have a dependency. (gh-…
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Jul 11, 2023
1 parent 22988c3 commit 115df84
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Lib/test/test_compile.py
Expand Up @@ -1186,6 +1186,15 @@ def f(x, y, z):
return a
self.assertEqual(f("x", "y", "z"), "y")

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


@requires_debug_ranges()
class TestSourcePositions(unittest.TestCase):
Expand Down

0 comments on commit 115df84

Please sign in to comment.