The mypyc plugin sets all modules inside a group as dependent on each other so they are part of a single SCC. When we compile the SCC, we compile its modules according to the order in scc.mod_ids. mod_ids is a set so the order is non-deterministic.
This might result in random failures when multiple files are compiled together and we have a bug in mypyc caused by relying on data that is dependent on the compilation order. For example if we are compiling two files a.py and b.py each with a single class and an attribute of ClassIR representing the class A that is not set during the preparation phase is used when compiling the class B, the result will depend on whether a.py was compiled before b.py.
To fix, make the order deterministic based on module names by sorting them first. Also sort the source files and groups passed to mypycify so that invoking mypyc a.py b.py and mypyc b.py a.py produces identical results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mypyc plugin sets all modules inside a group as dependent on each other so they are part of a single SCC. When we compile the SCC, we compile its modules according to the order in scc.mod_ids. mod_ids is a set so the order is non-deterministic.
This might result in random failures when multiple files are compiled together and we have a bug in mypyc caused by relying on data that is dependent on the compilation order. For example if we are compiling two files a.py and b.py each with a single class and an attribute of ClassIR representing the class A that is not set during the preparation phase is used when compiling the class B, the result will depend on whether a.py was compiled before b.py.
To fix, make the order deterministic based on module names by sorting them first. Also sort the source files and groups passed to mypycify so that invoking mypyc a.py b.py and mypyc b.py a.py produces identical results.