Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
If theapply_static_swaps optimization in the compiler sees the instruction sequenceSWAP 2; STORE_FAST a; STORE_FAST a, it will optimize that by removing theSWAP and swapping the two instructions, resulting inSTORE_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 toa.
This was exposed by comprehension inlining, since it can result in this bytecode sequence for code in the forma = [1 for a in [0]] (where the firstSTORE_FAST a is restoring the previous value ofa from before the comprehension, if any, and the secondSTORE_FAST a is storing the result of the comprehension toa.).
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status