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

Closed
JukkaL opened this issue Jan 16, 2019 · 2 comments
Closed

Semantic analyzer redesign #6204

JukkaL opened this issue Jan 16, 2019 · 2 comments
Assignees
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL 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
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.
@ilevkivskyi
Copy link
Member

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.

@JukkaL JukkaL added the semantic-analyzer Problems that happen during semantic analysis label Jun 13, 2019
@JukkaL
Copy link
Collaborator Author

JukkaL commented Jun 28, 2019

We've now officially released the new semantic analyzer as an experimental feature, enabled through --new-semantic-analyzer. There are still a few regressions, some of which may take a while to fix, but we can track those as separate issues.

@JukkaL JukkaL closed this as completed Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants