Support scoped keyword in declaration expressions.#64380
Support scoped keyword in declaration expressions.#64380AlekseyTs merged 6 commits intodotnet:mainfrom
scoped keyword in declaration expressions.#64380Conversation
|
@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.
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.
What is the difference between node.ModifyingScopedOrRefTypeOrSelf() and node.SkipScoped(out _).SkipRef(out _)? #Resolved
There was a problem hiding this comment.
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.
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.
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.