-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Support scoped keyword in declaration expressions.
#64380
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
Conversation
|
@cston, @RikkiGibson, @dotnet/roslyn-compiler Please review. |
|
@cston, @RikkiGibson, @dotnet/roslyn-compiler Please review. |
1 similar comment
|
@cston, @RikkiGibson, @dotnet/roslyn-compiler Please review. |
Consider testing: In reply to: 1267291775 Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs:11206 in 4df2321. [](commit_id = 4df2321, deletion_comment = False) |
Consider testing: In reply to: 1267317245 Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs:10647 in 4df2321. [](commit_id = 4df2321, deletion_comment = False) |
These errors look unnecessary. This might be #64448, if not already fixed in #64318. Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs:11540 in 4df2321. [](commit_id = 4df2321, deletion_comment = False) |
|
Is this change being considered for 17.4? |
Not at the moment. Do you think it should be? |
My preference would be to do it in 17.5. |
Consider testing: {
int i1 = 1;
(new S(ref i1)).M(out scoped S1);
s0 = s1;
}
{
int i1 = 1;
(new S(ref i1)).M(out var S1);
s0 = s1;
}
{
int i1 = 1;
(new S(ref i1)).M(out scoped var S1);
s0 = s1;
}Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs:12289 in 4df2321. [](commit_id = 4df2321, deletion_comment = False) |
cston
left a comment
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.
LGTM, with a few test suggestions.
|
@RikkiGibson, @dotnet/roslyn-compiler For the second review. |
2 similar comments
|
@RikkiGibson, @dotnet/roslyn-compiler For the second review. |
|
@RikkiGibson, @dotnet/roslyn-compiler For the second review. |
|
@RikkiGibson, @dotnet/roslyn-compiler For the second review. |
1 similar comment
|
@RikkiGibson, @dotnet/roslyn-compiler For the second review. |
I am having a hard time mapping this question to a specific location in source. Could you repost it relative to the current state of the branch? |
The comment was referring to the error reported for |
|
I cannot comment about reasons why the errors are reported, simply didn't dig into that. The behavior is consistent with behavior when out var declaration isn't used: |
| { | ||
| parent = node.Parent as DeclarationExpressionSyntax; | ||
| return node == parent?.Type; | ||
| parent = node.ModifyingScopedOrRefTypeOrSelf().Parent as DeclarationExpressionSyntax; |
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.
What is the difference between node.ModifyingScopedOrRefTypeOrSelf() and node.SkipScoped(out _).SkipRef(out _)? #Resolved
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.
What is the difference between
node.ModifyingScopedOrRefTypeOrSelf()andnode.SkipScoped(out _).SkipRef(out _)?
ModifyingScopedOrRefTypeOrSelf goes up (to the parent), "skip" helpers go down (to the child). They are, effectively, opposite operations.
| var discard = tree.GetRoot().DescendantNodes().OfType<DiscardDesignationSyntax>().ToArray(); | ||
| Assert.Equal(8, discard.Length); | ||
|
|
||
| for (int i = 0; i < 6; i++) |
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 didn't understand why the last 2 discard elements are not checked (since length was asserted to be 8 above). #Resolved
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 didn't understand why the last 2 discard elements are not checked (since length was asserted to be 8 above).
The last two discards refer to an undeclared type, do not align with the rest, and are not really interesting for the purpose of the test.
Related to #62039.
https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md#syntax
Also fixes #64259.