Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jul 3, 2019

We special case these since a more general fix, such as looking
at line numbers of definitions, would break a ton of test cases.

Fixes #6404.

@JukkaL JukkaL requested a review from ilevkivskyi July 3, 2019 15:47
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.

Special-casing this makes sense. I have couple minor suggestions.

# Fall back to normal assignment analysis.
return False
else:
self.defer()
Copy link
Member

Choose a reason for hiding this comment

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

name_not_defined() currently already calls defer(), is this additional defer actually needed?

Also this returns True, I would make it more clear by putting the return directly here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The fact that name_not_defined calls defer requires some pretty subtle reasoning so I'd rather keep make it explicit here.

node.node = sym.node
node.kind = GDEF
node.fullname = sym.node.fullname()
return True
Copy link
Member

Choose a reason for hiding this comment

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

With the above this return can be indented one level more.

[case testNewAnalyzerIdentityAssignment8]
from typing import Final
x: Final = 0
x = x # E: Cannot assign to final name "x"
Copy link
Member

Choose a reason for hiding this comment

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

Great to see so detailed test cases!

@JukkaL JukkaL merged commit 1bce150 into master Jul 4, 2019
@ilevkivskyi ilevkivskyi deleted the semanal-assign-self branch September 12, 2019 10:03
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.

New semantic analyzer: Support idem forward aliases

3 participants