-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Implement AstNode
for Identifier
#13207
Conversation
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 reasonable to me! @MichaReiser is probably the better reviewer on this, though
|
Nice! Does this also mean that we'd now be able to just store the identifier directly as an Or it may turn out that indices are nicer to work with than the node references, in which case we'd rather change assignments to use indices instead :) So maybe this is just something to consider when working on actually implementing unpacking assignment. |
Yeah, although I think index might still be better to identify the type. This provides us the position of the identifier in the pattern, then we'll kinda zip through the subject / pattern to perform structural matching until we reach the index position. Without the index, we will have to compare each identifier in the pattern to determine the one that we're looking to determine the type for. Does this make sense? I can provide an example as well. |
It does make sense; that's what I was thinking of when I said "it may turn out indices are nicer to work with." My main thought is that when we do unpacking, we should probably settle on a preference for either indices or node refs for these unpacking targets, and make them all work as similarly as possible (whichever way we decide is best), because I don't see a strong rationale for them to be different. |
Summary
Follow-up to #13147, this PR implements the
AstNode
forIdentifier
. This makes it easier to create theNodeKey
in red knot because it uses a generic method to construct the key fromAnyNodeRef
and is important for definitions that are created only on identifiers instead ofExprName
.Test Plan
cargo test
andcargo clippy