-
Notifications
You must be signed in to change notification settings - Fork 424
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
Resolving nil assignments in record initialization #26031
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99f4c48
code for the resolution, but the opcall intents are still not sorted.
brandon-neth d6842be
simplified logic.
brandon-neth d530bde
test based on github issue code
brandon-neth bbc7c26
updated tests
brandon-neth 538f734
fixed nullptr segfault
brandon-neth 7f81b49
whitespace and matching lhs to rhs
brandon-neth 0ee005a
Ben's feedback on PR
brandon-neth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,6 +129,9 @@ class InitResolver { | |
|
||
public: | ||
|
||
//initialization points to guide handling `=` operators | ||
std::set<const uast::AstNode*> initPoints; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better to add a method on InitResolver that returns true if a given AstNode is field initialization. |
||
|
||
static owned<InitResolver> | ||
create(Context* context, Resolver& visitor, const uast::Function* fn); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Notably (see above) the state
qt
is still determined fromreRhs
type, which I don't think is right. Later on in the process (seecomputeReceiverTypeConsideringState
, the QT of the state is used for constructing instantiations explicitly. I don't think this is right, since in this particular case, this will lead to usingnull
(the type) as the field type.Does call-init-deinit re-run field resolution with results of
init=
? If not, I think this will lead to incorrect instantiations.To see this, try with a generic class field.
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 don't think call-init-deinit reruns field resolution; it looks like it assumes the field types have been resolved already.
Could you elaborate on why a generic class field would expose this behavior? I think there's holes in my understanding of the process for generics here.
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.
Well, there's a bunch of logic that computes the field types / field substitutions for a generic type when it's being constructed. E.g., so that:
Leads to a type where
myTypeField
has anint
substitution. This is only necessary for generic fields (because concrete fields don't need instantiations). This is why I'm telling you to try with a generic field (and it needs to be a class field so thatnil
can be legally assigned to it).chapel/frontend/lib/resolution/InitResolver.cpp
Line 361 in 939475f
When inserting the substitutions, it looks like the type of
state->qt
is used directly.chapel/frontend/lib/resolution/InitResolver.cpp
Lines 364 to 365 in 939475f
This means that, since your PR doesn't change
state->qt
from its original (RHS) value, a generic field being instantiated usingnil
will get the type ofnil
. I don't think that is what you want.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.
The thing I'm concretely telling you to try is something like the following: