Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantic analyzer redesign #6204

JukkaL opened this issue Jan 16, 2019 · 1 comment


None yet
2 participants
Copy link

commented Jan 16, 2019

We are planning to do a major update to how the semantic analyzer works. The main idea is to use "deferred nodes" to allow each AST node to be processed an arbitrary number of times until all dependencies are ready. This may be needed to bind names within import cycles, for example. This should allow us to fix various issues with forward references and import cycles. We also hope that it will make it relatively easy to support general recursive types.

While the new design is in development, we'll have two semantic analyzer implementations available. We'll replace the existing semantic analyzer with the new one once the latter works well enough. Before that the new semantic analyzer must be explicitly enabled with a command-line option.

The new design should be strictly better than the current one, but there will likely some backward compatibility issues with existing plugins.

JukkaL added a commit that referenced this issue Jan 23, 2019

Initial work towards new semantic analyzer (#6240)
Implement basic deferred nodes functionality and remove most of old
pass 1 functionality. Also fork `mypy.semanal_shared` since I needed
to tweak the signature of anal_type in an incompatible way (there are
not other changes in that module).

A lot of things still don't work, including functions and more than two
passes. There are a small number of tests for the new semantic
analyzer, but I made no attempt at achieving good test coverage yet.

Work towards #6204.

This comment has been minimized.

Copy link

commented Feb 11, 2019

Another thing (reminded by #3459) that we should do soon is write more docs about the deferral/completeness logic. Some details are missing in the docstrings, it is better not to postpone this until after we make new analyzer default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.