Support parsing for Unsigned Right Shift operator#60501
Support parsing for Unsigned Right Shift operator#60501AlekseyTs merged 3 commits intodotnet:features/UnsignedRightShiftfrom
Conversation
| NoTriviaBetween(opToken2, tk)) // no trailing trivia and no leading trivia | ||
| { | ||
| opToken2 = this.EatToken(); | ||
| opToken = SyntaxFactory.Token(opToken.GetLeadingTrivia(), SyntaxKind.GreaterThanGreaterThanGreaterThanToken, opToken2.GetTrailingTrivia()); |
There was a problem hiding this comment.
Should MergeAdjacent be used? #Resolved
There was a problem hiding this comment.
Should MergeAdjacent be used?
I am not inventing new ways of doing things, simply following what we do for SyntaxKind.GreaterThanGreaterThanToken.
| operatorToken.ValueText + operatorToken2.ValueText + operatorToken3.ValueText, | ||
| operatorToken3.GetTrailingTrivia()); | ||
|
|
||
| operatorToken = SyntaxFactory.MissingToken(SyntaxKind.PlusToken); |
There was a problem hiding this comment.
not entirely clear waht's going on here. Is x >>>= 1 not allowed?
There was a problem hiding this comment.
oh. this is doc comment parsing. n/m/
There was a problem hiding this comment.
fwiw, there feels like there's a lot of overlap between this and the same logic below for >>=. consider extracting a local function to help out here.
| operatorToken.Text + operatorToken2.Text + operatorToken3.Text, | ||
| operatorToken.ValueText + operatorToken2.ValueText + operatorToken3.ValueText, | ||
| operatorToken3.GetTrailingTrivia()); | ||
|
|
There was a problem hiding this comment.
Why use a PlusToken, and not a GreaterThanToken? #Resolved
There was a problem hiding this comment.
Why use a PlusToken, and not a GreaterThanToken?
Simply following the existing behavior on line 1092
| @@ -10639,25 +10650,42 @@ private ExpressionSyntax ParseExpressionContinued(ExpressionSyntax leftOperand, | |||
| var newPrecedence = GetPrecedence(opKind); | |||
|
|
|||
| // check for >> or >>= | |||
There was a problem hiding this comment.
Consider updating this comment. #Resolved
| @@ -3720,12 +3722,106 @@ void M() | |||
| var j = e is a < i >>> 2; | |||
There was a problem hiding this comment.
Consider removing the comment above this line. #Closed
| { | ||
| void M() | ||
| { | ||
| var added = ImmutableDictionary<T<S>>> |
There was a problem hiding this comment.
Would it be useful to have a test with a tuple type next to the >>> as well? #Resolved
There was a problem hiding this comment.
Would it be useful to have a test with a tuple type next to the
>>>as well?
I am not aware of any specific reason why this could be useful, other than the fact that any test potentially has some value. Also, I think there is no test like that for >>, so I assume there isn't anything special there.
|
@jcouv, @dotnet/roslyn-compiler For the second review. |
1 similar comment
|
@jcouv, @dotnet/roslyn-compiler For the second review. |
| } | ||
| } | ||
| EOF(); | ||
| } |
There was a problem hiding this comment.
nit: I was trying to brainstorm cases to tests. Scenarios like is A<B<C<T>>>, as A<B<C<T>>>, (A<B<C<T>>>, Type) a = ... are probably already covered (plus those relate to parsing types, not parsing expressions).
So maybe a legit expression scenario: a < b < c < t >>> n, or an incremental scenario transitioning from type to expression or vice-versa?
| { | ||
| foreach (var options in new[] { TestOptions.RegularPreview, TestOptions.Regular10, TestOptions.RegularNext }) | ||
| { | ||
| UsingExpression("x >> >= y", options, |
There was a problem hiding this comment.
Consider a test similar to:
_ = x switch
{
A<B<C<D>>>=> 0,
}|
I'll follow up on test suggestions separately. |
https://github.com/dotnet/csharplang/blob/main/proposals/unsigned-right-shift-operator.md
Test plan #60433