-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: generalize placeholders to all symbol nodes #6336
Conversation
We don't still do anything useful with the node.
The use of 'missing_names' will prevent an invalid placeholder from being created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good! I just have one question.
if self.is_alias_for_final_name(lval.name): | ||
if lvalue.node: | ||
# This has been bound already in a previous iteration. | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we do this for names but not for attributes? Maybe leave a comment/TODO about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create an issue about dealing with attribute definitions (through self.x
).
This generalizes the concept of placeholder nodes to also cover
assignment statements and imports. Previously they were only
created for class definitions. The main motivation is to prevent
access to definitions in outer namespaces if there is an
incomplete definition that should take precedence.
Fixes #6299.
This also does a few other updates:
generate an error instead of producing placeholder nodes. This
allows the analysis to terminate in certain cases of import
cycles at least.
analyze_name_lvalue
. The motivation isthat some early experiments made the old structure unwieldy,
but the refactoring may not be as important for the final design.
This seems like a code quality improvement so I'm including it
here.
rebind it. I'd like to gradually move to this approach more
generally.
any more. I think that these worked by accident. Now these
generally generate "cannot determine type" errors.
more, since placeholders count as definitions in this context.
Star imports still generate incomplete namespaces.