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

New semantic analyzer: Remove temporary Var's for TypedDict and NamedTuple #6453

Closed
ilevkivskyi opened this issue Feb 20, 2019 · 0 comments · Fixed by #6527
Closed

New semantic analyzer: Remove temporary Var's for TypedDict and NamedTuple #6453

ilevkivskyi opened this issue Feb 20, 2019 · 0 comments · Fixed by #6527
Assignees
Labels
priority-1-normal semantic-analyzer Problems that happen during semantic analysis

Comments

@ilevkivskyi
Copy link
Member

These are used to be compatible with the old semantic analyzer.

@ilevkivskyi ilevkivskyi added priority-1-normal semantic-analyzer Problems that happen during semantic analysis labels Feb 20, 2019
@ilevkivskyi ilevkivskyi self-assigned this Mar 7, 2019
ilevkivskyi added a commit that referenced this issue Mar 15, 2019
…rward (#6527)

Fixes #6412 
Fixes #6453 

In this PR:
* Wait until we can classify r.h.s. of an assignment as normal, type alias, named tuple etc.
* Choose the corresponding branch instead of performing all of them (as it used to be before)
* Never create (or rely on creation of) temporary `Var`s
* Add every symbol to symbol table only once (as it is done for classes)
* Don't "patch" existing symbols (with one exception for type variables, see below)
* Add and update docstrings and comments

Notes:
* I allow placeholders for type alias targets and NewTypes targets, they essentially behave as base classes. In general I make logic for type aliases and NewTypes much more similar to logic of class definitions (especially NewTypes), this allows to support a whole bunch of tricky forward references
* I don't store types with placeholders in annotations, and instead if an alias target got updated (e.g. placeholders are resolved), I set `progress=True`

Follow-ups:
* There is still a small hack to keep compatibility with old analyzer in type checker, but now it is basically "don't use binder for l.h.s. of special forms"
* Type variable declarations still have a bug that duplicate type variable definition is not reported as error, second one silently wins, this will be fixed in a separate PR
* This PR doesn't aim to fix aspects of assignment analysis related to #6422, that will be also a separate PR

Test updates:
* Add and enable more tests for type aliases and NewTypes
* Add test for cyclic definition error messages
* Change order of error messages on the same line in few tests
* Enable one test file where previously only some tests were opted in (I think it was not enabled by mistake in one of the previous PRs, I enable it here since order of errors in one test in that file is affected by this PR.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-1-normal semantic-analyzer Problems that happen during semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant