Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain the purpose of the test in a comment? From the code, it's nonibvious to me how it can be miscompiled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain the purpose of the test in a comment? From the code, it's nonibvious to me how it can be miscompiled.

No, it doesn't miscompile at this optimization moment.
But I was quite surprised with the CI never failed with the wrong compile for the #106571 (comment).
So it could be good to be added. I thought that miscompile case should be caught at the CI level.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't say that the code is miscompiled. I propose adding a comment to explain that the test checks that this specific code is not miscompiled, but please explain why it could be miscompiled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

# 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