Description
If the apply_static_swaps
optimization in the compiler sees the instruction sequence SWAP 2; STORE_FAST a; STORE_FAST a
, it will optimize that by removing the SWAP
and swapping the two instructions, resulting in STORE_FAST a; STORE_FAST a
.
But of course, in this case the two instructions are identical, and their ordering matters because they store to the same location. So this change results in the wrong value being stored to a
.
This was exposed by comprehension inlining, since it can result in this bytecode sequence for code in the form a = [1 for a in [0]]
(where the first STORE_FAST a
is restoring the previous value of a
from before the comprehension, if any, and the second STORE_FAST a
is storing the result of the comprehension to a
.).
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status