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: fix crash related to dataclasses.InitVar #6984

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jun 13, 2019

Previously InitVar attributes were missing on the second semantic
analysis pass, since the dataclasses plugin removes those attributes
from the class symbol table. This caused a crash. The fix is to reset
the attribute declarations so that they will be re-added to the symbol
table on successive semantic analysis passes.

Fixes #6955.

Previously InitVar attributes were missing on the second semantic
analysis pass, since the dataclasses plugin removes those attributes
from the class symbol table. This caused a crash. The fix is to reset
the attribute declarations so that they will be re-added to the symbol
table on successive semantic analysis passes.

Fixes #6955.
@JukkaL JukkaL requested a review from ilevkivskyi June 13, 2019 12:59
Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one question about a flag in test.

@@ -520,6 +520,26 @@ app.database_name # E: "SpecializedApplication" has no attribute "database_name

[builtins fixtures/list.pyi]

[case testDataclassesInitVarsAndDefer]
# flags: --new-semantic-analyzer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually needed? Or it doesn't work well with the old analyzer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but I added it since the test case doesn't test anything useful on the old analyzer and I didn't want to add it to check-newsemanal.test. We may want to move test cases out of check-newsemanal.test to other files once we've removed the old semantic analyzer, and this is anticipating that move.

@JukkaL JukkaL merged commit 7692f56 into master Jun 13, 2019
@JelleZijlstra JelleZijlstra deleted the semanal-plugins branch June 13, 2019 16:31
PattenR pushed a commit to PattenR/mypy that referenced this pull request Jun 23, 2019
…on#6984)

Previously InitVar attributes were missing on the second semantic
analysis pass, since the dataclasses plugin removes those attributes
from the class symbol table. This caused a crash. The fix is to reset
the attribute declarations so that they will be re-added to the symbol
table on successive semantic analysis passes.

Fixes python#6955.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dataclasses.InitVar crashes on new analyzer
2 participants