From c4f185490f7dfba16f4dcc0add76b722c4d4f288 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 6 Mar 2026 10:20:05 -0500 Subject: [PATCH 1/8] Support unsigned right shift operator Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/lexical-structure.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/standard/lexical-structure.md b/standard/lexical-structure.md index 86a73301c..e505878be 100644 --- a/standard/lexical-structure.md +++ b/standard/lexical-structure.md @@ -1051,11 +1051,19 @@ right_shift right_shift_assignment : '>' '>=' ; + +unsigned_right_shift + : '>' '>' '>' + ; + +unsigned_right_shift_assignment + : '>' '>' '>=' + ; ``` -> *Note*: *right_shift* and *right_shift_assignment* are parser rules as they do not introduce a new token kind but represent a sequence of two tokens. The *operator_or_punctuator* rule exists for descriptive purposes only and is not used elsewhere in the grammar. *end note* +> *Note*: *right_shift* and *right_shift_assignment* are parser rules as they do not introduce a new token kind but represent a sequence of two tokens. Similarly, *unsigned_right_shift* and *unsigned_right_shift_assignment* are parser rules as they do not introduce a new token kind but represent a sequence of three tokens. The *operator_or_punctuator* rule exists for descriptive purposes only and is not used elsewhere in the grammar. *end note* -*right_shift* is made up of the two tokens `>` and `>`. Similarly, *right_shift_assignment* is made up of the two tokens `>` and `>=`. Unlike other productions in the syntactic grammar, no characters of any kind (not even whitespace) are allowed between the two tokens in each of these productions. These productions are treated specially in order to enable the correct handling of *type_parameter_lists* ([§15.2.3](classes.md#1523-type-parameters)). +*right_shift* is made up of the two tokens `>` and `>`, and *unsigned_right_shift* is made up of the three tokens `>`, `>`, and `>`. Similarly, *right_shift_assignment* is made up of the two tokens `>` and `>=`, and *unsigned_right_shift_assignment* is made up of the three tokens `>`, `>`, and `>=`. Unlike other productions in the syntactic grammar, no characters of any kind (not even whitespace) are allowed between the two tokens in each of these productions. These productions are treated specially in order to enable the correct handling of *type_parameter_lists* ([§15.2.3](classes.md#1523-type-parameters)). > *Note*: Prior to the addition of generics to C#, `>>` and `>>=` were both single tokens. However, the syntax for generics uses the `<` and `>` characters to delimit type parameters and type arguments. It is often desirable to use nested constructed types, such as `List>`. Rather than requiring the programmer to separate the `>` and `>` by a space, the definition of the two *operator_or_punctuator*s was changed. *end note* From ccbaba2815fe8523c61e2117f66845a629f0955a Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 6 Mar 2026 10:38:34 -0500 Subject: [PATCH 2/8] support unsigned right shift operator Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/expressions.md | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/standard/expressions.md b/standard/expressions.md index 142e87ff6..5932a85e0 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -67,8 +67,8 @@ The following operations in C# are subject to binding: - Element access: `e[e₁,...,eᵥ]` - Object creation: new `C(e₁,...,eᵥ)` - Overloaded unary operators: `+`, `-`, `!` (logical negation only), `~`, `++`, `--`, `true`, `false` -- Overloaded binary operators: `+`, `-`, `*`, `/`, `%`, `&`, `&&`, `|`, `||`, `??`, `^`, `<<`, `>>`, `==`, `!=`, `>`, `<`, `>=`, `<=` -- Assignment operators: `=`, `= ref`, `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, `??=` +- Overloaded binary operators: `+`, `-`, `*`, `/`, `%`, `&`, `&&`, `|`, `||`, `??`, `^`, `<<`, `>>`, `>>>` (static binding only), `==`, `!=`, `>`, `<`, `>=`, `<=` +- Assignment operators: `=`, `= ref`, `+=`, `-=`, `*=`, `/=`, `%=`, `&=`, `|=`, `^=`, `<<=`, `>>=`, `>>>=` (static binding only), `??=` - Implicit and explicit conversions When no dynamic expressions are involved, C# defaults to static binding, which means that the compile-time types of subexpressions are used in the selection process. However, when one of the subexpressions in the operations listed above is a dynamic expression, the operation is instead dynamically bound. @@ -160,7 +160,7 @@ The precedence of an operator is established by the definition of its associated > | [§12.12](expressions.md#1212-switch-expression) | Switch | `switch { … }` | > | [§12.13](expressions.md#1213-arithmetic-operators) | Multiplicative | `*` `/` `%` | > | [§12.13](expressions.md#1213-arithmetic-operators) | Additive | `+` `-` | -> | [§12.14](expressions.md#1214-shift-operators) | Shift | `<<` `>>` | +> | [§12.14](expressions.md#1214-shift-operators) | Shift | `<<` `>>` `>>>` | > | [§12.15](expressions.md#1215-relational-and-type-testing-operators) | Relational and type-testing | `<` `>` `<=` `>=` `is` `as` | > | [§12.15](expressions.md#1215-relational-and-type-testing-operators) | Equality | `==` `!=` | > | [§12.16](expressions.md#1216-logical-operators) | Logical AND | `&` | @@ -170,7 +170,7 @@ The precedence of an operator is established by the definition of its associated > | [§12.17](expressions.md#1217-conditional-logical-operators) | Conditional OR | `\|\|` | > | [§12.18](expressions.md#1218-the-null-coalescing-operator) and [§12.19](expressions.md#1219-the-throw-expression-operator) | Null coalescing and throw expression | `??` `throw x` | > | [§12.21](expressions.md#1221-conditional-operator) | Conditional | `?:` | -> | [§12.24](expressions.md#1224-assignment-operators) and [§12.22](expressions.md#1222-anonymous-function-expressions) | Assignment and lambda expression | `=` `= ref` `*=` `/=` `%=` `+=` `-=` `<<=` `>>=` `&=` `^=` `\|=` `=>` `??=` | +> | [§12.24](expressions.md#1224-assignment-operators) and [§12.22](expressions.md#1222-anonymous-function-expressions) | Assignment and lambda expression | `=` `= ref` `*=` `/=` `%=` `+=` `-=` `<<=` `>>=` `>>>=` `&=` `^=` `\|=` `=>` `??=` | > > *end note* @@ -201,7 +201,7 @@ Only the operators listed above can be overloaded. In particular, it is not poss The ***overloadable binary operator***s are: -> `+ - * / % & | ^ << >> == != > < <= >=` +> `+ - * / % & | ^ << >> >>> == != > < <= >=` Only the operators listed above can be overloaded. In particular, it is not possible to overload member access, method invocation, or the `..`, `=`, `&&`, `||`, `??`, `?:`, `=>`, `checked`, `unchecked`, `new`, `typeof`, `default`, `as`, and `is` operators. @@ -358,7 +358,7 @@ In both of the above cases, a cast expression can be used to explicitly convert A ***lifted operator*** permits predefined and user-defined operators that operate on a non-nullable value type to also be used with the nullable form of that type. Lifted operators are constructed from predefined and user-defined operators that meet certain requirements, as described in the following: - For the unary operators `+`, `++`, `-`, `--`, `!` (logical negation), `^`, and `~`, a lifted form of an operator exists if the operand and result types are both non-nullable value types. The lifted form is constructed by adding a single `?` modifier to the operand and result types. The lifted operator produces a `null` value if the operand is `null`. Otherwise, the lifted operator unwraps the operand, applies the underlying operator, and wraps the result. -- For the binary operators `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `..`, `<<`, and `>>`, a lifted form of an operator exists if the operand and result types are all non-nullable value types. The lifted form is constructed by adding a single `?` modifier to each operand and result type. The lifted operator produces a `null` value if one or both operands are `null` (an exception being the `&` and `|` operators of the `bool?` type, as described in [§12.16.5](expressions.md#12165-nullable-boolean--and--operators)). Otherwise, the lifted operator unwraps the operands, applies the underlying operator, and wraps the result. +- For the binary operators `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `..`, `<<`, `>>`, and `>>>`, a lifted form of an operator exists if the operand and result types are all non-nullable value types. The lifted form is constructed by adding a single `?` modifier to each operand and result type. The lifted operator produces a `null` value if one or both operands are `null` (an exception being the `&` and `|` operators of the `bool?` type, as described in [§12.16.5](expressions.md#12165-nullable-boolean--and--operators)). Otherwise, the lifted operator unwraps the operands, applies the underlying operator, and wraps the result. - For the equality operators `==` and `!=`, a lifted form of an operator exists if the operand types are both non-nullable value types and if the result type is `bool`. The lifted form is constructed by adding a single `?` modifier to each operand type. The lifted operator considers two `null` values equal, and a `null` value unequal to any non-`null` value. If both operands are non-`null`, the lifted operator unwraps the operands and applies the underlying operator to produce the `bool` result. - For the relational operators `<`, `>`, `<=`, and `>=`, a lifted form of an operator exists if the operand types are both non-nullable value types and if the result type is `bool`. The lifted form is constructed by adding a single `?` modifier to each operand type. The lifted operator produces the value `false` if one or both operands are `null`. Otherwise, the lifted operator unwraps the operands and applies the underlying operator to produce the `bool` result. @@ -4600,22 +4600,29 @@ Lifted ([§12.4.8](expressions.md#1248-lifted-operators)) forms of the unlifted ## 12.14 Shift operators -The `<<` and `>>` operators are used to perform bit-shifting operations. +The `<<`, `>>`, and `>>>` operators are used to perform bit-shifting operations. ```ANTLR shift_expression : additive_expression | shift_expression '<<' additive_expression | shift_expression right_shift additive_expression + | shift_expression unsigned_right_shift additive_expression ; ``` If an operand of a *shift_expression* has the compile-time type `dynamic`, then the expression is dynamically bound ([§12.3.3](expressions.md#1233-dynamic-binding)). In this case, the compile-time type of the expression is `dynamic`, and the resolution described below will take place at run-time using the run-time type of those operands that have the compile-time type `dynamic`. -For an operation of the form `x << count` or `x >> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator. +Dynamic binding uses values of type `enum System.Linq.Expressions.ExpressionType` to communicate binary operator kind to the runtime binder. As there is no enum member specifically representing an unsigned right shift operator, dynamic binding for `>>>` is not supported. + +For an operation of the form `x << count`, `x >> count`, or `X >>> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The left operand is converted to type `T`, where `T` is the first of `int`, `uint`, `long`, and `ulong` that can fully represent all possible values of the operand. The operation is then performed using the precision of type `T`, and the type of the result is `T`. When declaring an overloaded shift operator, the type of the first operand shall always be the class or struct containing the operator declaration, and the type of the second operand shall always be `int`. +The *unsigned_right_shift* operator (`>>>`) shall not be present in an expression tree. + +> *Note*: The semantics of the predefined `>>>` operator on signed types cannot be accurately represented without adding conversions to an unsigned type and back. *end note* + The predefined shift operators are listed below. - Shift left: @@ -4641,6 +4648,12 @@ The predefined shift operators are listed below. nuint operator >>(nuint x, int count); long operator >>(long x, int count); ulong operator >>(ulong x, int count); + int operator >>>(int x, int count); + uint operator >>>(uint x, int count); + nint operator >>>(nint x, int count); + nuint operator >>>(nuint x, int count); + long operator >>>(long x, int count); + ulong operator >>>(ulong x, int count); ``` The `>>` operator shifts `x` right by a number of bits computed as described below. @@ -4649,6 +4662,8 @@ The predefined shift operators are listed below. When `x` is of type `uint`, `nuint`, or `ulong`, the low-order bits of `x` are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero. + The `>>>` operator shifts `x` right by a number of bits computed as follows: The low-order bits of `x` are discarded, the remaining bits are shifted right, and the high-order empty bit positions are set to zero. + For the predefined operators, the number of bits to shift is computed as follows: - When the type of `x` is `int` or `uint`, the shift count is given by the low-order five bits of `count`. In other words, the shift count is computed from `count & 0x1F`. This also applies when the type of `x` is `nint` or `nuint`, and those types have the same size and representation as `int` and `uint`, respectively. @@ -7185,6 +7200,9 @@ assignment | simple_assignment | compound_assignment | ref_assignment + | right_shift_assignment + | unsigned_right_shift_assignment + : unary_expression assignment_operator expression ; ``` @@ -7687,7 +7705,7 @@ Only the following constructs are permitted in constant expressions: - `checked` and `unchecked` expressions. - `nameof` expressions. - The predefined `+`, `-`, `!` (logical negation) and `~` unary operators. -- The predefined `+`, `-`, `*`, `/`, `%`, `<<`, `>>`, `&`, `|`, `^`, `&&`, `||`, `==`, `!=`, `<`, `>`, `<=`, and `>=` binary operators. +- The predefined `+`, `-`, `*`, `/`, `%`, `<<`, `>>`, `>>>`, `&`, `|`, `^`, `&&`, `||`, `==`, `!=`, `<`, `>`, `<=`, and `>=` binary operators. - The `?:` conditional operator. - The `!` null-forgiving operator ([§12.8.9](expressions.md#1289-null-forgiving-expressions)). - `sizeof` expressions, provided the unmanaged-type is one of the types specified in [§24.6.9](unsafe-code.md#2469-the-sizeof-operator) for which `sizeof` returns a constant value. From 7455865c54de146808c9e01ce527b636a7ae36b6 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 6 Mar 2026 10:42:05 -0500 Subject: [PATCH 3/8] support unsigned right shift operator Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/classes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index 7f702e22f..a4ba75fa0 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -4991,7 +4991,7 @@ binary_operator_declarator overloadable_binary_operator : '+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '<<' - | right_shift | '==' | '!=' | '>' | '<' | '>=' | '<=' + | right_shift | unsigned_right_shift | '==' | '!=' | '>' | '<' | '>=' | '<=' ; conversion_operator_declarator @@ -5086,7 +5086,7 @@ The `true` and `false` unary operators require pair-wise declaration. A compile- The following rules apply to binary operator declarations, where `T` denotes the instance type of the class or struct that contains the operator declaration: - A binary non-shift operator shall take two parameters, at least one of which shall have type `T` or `T?`, and can return any type. -- A binary `<<` or `>>` operator ([§12.14](expressions.md#1214-shift-operators)) shall take two parameters, the first of which shall have type `T` or `T?` and the second of which shall have type `int` or `int?`, and can return any type. +- A binary `<<`, `>>`, or `>>>` operator ([§12.14](expressions.md#1214-shift-operators)) shall take two parameters, the first of which shall have type `T` or `T?` and the second of which shall have type `int` or `int?`, and can return any type. The signature of a binary operator consists of the operator token (`+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, `>>`, `==`, `!=`, `>`, `<`, `>=`, or `<=`) and the types of the two parameters. The return type and the names of the parameters are not part of a binary operator’s signature. From 434464b829109b42f60375b6a35009a9b3801c8e Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 6 Mar 2026 10:44:16 -0500 Subject: [PATCH 4/8] support unsigned right shift operator Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/documentation-comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/documentation-comments.md b/standard/documentation-comments.md index a6dbfbde9..1ce4db128 100644 --- a/standard/documentation-comments.md +++ b/standard/documentation-comments.md @@ -984,7 +984,7 @@ IDs: "M:Acme.Widget.op_Addition(Acme.Widget,Acme.Widget)" ``` -The complete set of binary operator function names used is as follows: `op_Addition`, `op_Subtraction`, `op_Multiply`, `op_Division`, `op_Modulus`, `op_BitwiseAnd`, `op_BitwiseOr`, `op_ExclusiveOr`, `op_LeftShift`, `op_RightShift`, `op_Equality`, `op_Inequality`, `op_LessThan`, `op_LessThanOrEqual`, `op_GreaterThan`, and `op_GreaterThanOrEqual`. +The complete set of binary operator function names used is as follows: `op_Addition`, `op_Subtraction`, `op_Multiply`, `op_Division`, `op_Modulus`, `op_BitwiseAnd`, `op_BitwiseOr`, `op_ExclusiveOr`, `op_LeftShift`, `op_RightShift`, `op_UnsignedRightShift`, `op_Equality`, `op_Inequality`, `op_LessThan`, `op_LessThanOrEqual`, `op_GreaterThan`, and `op_GreaterThanOrEqual`. **Conversion operators** have a trailing “`~`” followed by the return type. When either the source or destination of a conversion operator is a generic type, the “`<`” and “`">`” characters are replaced by the “`{`” and “`}`” characters, respectively. From ddbd2d60ccc52c1efd9a281e500415017053a5af Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Mon, 4 May 2026 13:27:19 -0400 Subject: [PATCH 5/8] Review and update Update some of the grammar, and a few normative rules Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 21570b74-c6f5-4fc5-ab6d-7546918d6ddb Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/classes.md | 2 +- standard/expressions.md | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index a4ba75fa0..fe7b6d53e 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -5088,7 +5088,7 @@ The following rules apply to binary operator declarations, where `T` denotes the - A binary non-shift operator shall take two parameters, at least one of which shall have type `T` or `T?`, and can return any type. - A binary `<<`, `>>`, or `>>>` operator ([§12.14](expressions.md#1214-shift-operators)) shall take two parameters, the first of which shall have type `T` or `T?` and the second of which shall have type `int` or `int?`, and can return any type. -The signature of a binary operator consists of the operator token (`+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, `>>`, `==`, `!=`, `>`, `<`, `>=`, or `<=`) and the types of the two parameters. The return type and the names of the parameters are not part of a binary operator’s signature. +The signature of a binary operator consists of the operator token (`+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, `>>`, `>>>`, `==`, `!=`, `>`, `<`, `>=`, or `<=`) and the types of the two parameters. The return type and the names of the parameters are not part of a binary operator’s signature. Certain binary operators require pair-wise declaration. For every declaration of either operator of a pair, there shall be a matching declaration of the other operator of the pair. Two operator declarations match if identity conversions exist between their return types and their corresponding parameter types. The following operators require pair-wise declaration: diff --git a/standard/expressions.md b/standard/expressions.md index 5932a85e0..d0233f20e 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -4615,7 +4615,7 @@ If an operand of a *shift_expression* has the compile-time type `dynamic`, then Dynamic binding uses values of type `enum System.Linq.Expressions.ExpressionType` to communicate binary operator kind to the runtime binder. As there is no enum member specifically representing an unsigned right shift operator, dynamic binding for `>>>` is not supported. -For an operation of the form `x << count`, `x >> count`, or `X >>> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The left operand is converted to type `T`, where `T` is the first of `int`, `uint`, `long`, and `ulong` that can fully represent all possible values of the operand. The operation is then performed using the precision of type `T`, and the type of the result is `T`. +For an operation of the form `x << count`, `x >> count`, or `x >>> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The left operand is converted to type `T`, where `T` is the first of `int`, `uint`, `long`, and `ulong` that can fully represent all possible values of the operand. The operation is then performed using the precision of type `T`, and the type of the result is `T`. When declaring an overloaded shift operator, the type of the first operand shall always be the class or struct containing the operator declaration, and the type of the second operand shall always be `int`. @@ -7200,9 +7200,6 @@ assignment | simple_assignment | compound_assignment | ref_assignment - | right_shift_assignment - | unsigned_right_shift_assignment - : unary_expression assignment_operator expression ; ``` @@ -7586,6 +7583,7 @@ compound_assignment compound_assignment_operator : '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '??=' | right_shift_assignment + | unsigned_right_shift_assignment ; ``` From 8ced57500b9843286d14a5c7242b6caac8df8948 Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 30 Oct 2026 12:48:09 -0400 Subject: [PATCH 6/8] reserve op_xxx for >>> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/classes.md b/standard/classes.md index fe7b6d53e..624555b41 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -1562,7 +1562,7 @@ The following method names are reserved. While many have corresponding operators | `op_UnaryNegation` | `-` (unary) | | `op_UnaryPlus` | `+` (unary) | | `op_UnsignedRightShift` | (reserved for future use) | -| `op_UnsignedRightShiftAssignment` | (reserved) | +| `op_UnsignedRightShiftAssignment` | `>>>` | ## 15.4 Constants From 986cfe1abf4cdcb7568c3701b90eb8349e6dc13b Mon Sep 17 00:00:00 2001 From: Rex Jaeschke Date: Fri, 30 Oct 2026 12:51:43 -0400 Subject: [PATCH 7/8] fix op_xxx fix Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 361b9a77-2b4c-45e6-969f-e6785c47f27e --- standard/classes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index 624555b41..7b99b2bb0 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -1561,8 +1561,8 @@ The following method names are reserved. While many have corresponding operators | `op_True` | `true` | | `op_UnaryNegation` | `-` (unary) | | `op_UnaryPlus` | `+` (unary) | -| `op_UnsignedRightShift` | (reserved for future use) | -| `op_UnsignedRightShiftAssignment` | `>>>` | +| `op_UnsignedRightShift` | `>>>` | +| `op_UnsignedRightShiftAssignment` | (reserved) | ## 15.4 Constants From 5630ea6ac84619e0c58f7150f90d7a26e89cf9fa Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Tue, 17 Nov 2026 13:20:58 -0500 Subject: [PATCH 8/8] there can be three token productions in the right shift Update text to include the fact that the right shift production may include 3 adjacent required tokens. --- standard/expressions.md | 2 +- standard/lexical-structure.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/standard/expressions.md b/standard/expressions.md index d0233f20e..da2591c9d 100644 --- a/standard/expressions.md +++ b/standard/expressions.md @@ -4615,7 +4615,7 @@ If an operand of a *shift_expression* has the compile-time type `dynamic`, then Dynamic binding uses values of type `enum System.Linq.Expressions.ExpressionType` to communicate binary operator kind to the runtime binder. As there is no enum member specifically representing an unsigned right shift operator, dynamic binding for `>>>` is not supported. -For an operation of the form `x << count`, `x >> count`, or `x >>> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The left operand is converted to type `T`, where `T` is the first of `int`, `uint`, `long`, and `ulong` that can fully represent all possible values of the operand. The operation is then performed using the precision of type `T`, and the type of the result is `T`. +For an operation of the form `x << count`, `x >> count`, or `x >>> count`, binary operator overload resolution ([§12.4.5](expressions.md#1245-binary-operator-overload-resolution)) is applied to select a specific operator implementation. The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator. When declaring an overloaded shift operator, the type of the first operand shall always be the class or struct containing the operator declaration, and the type of the second operand shall always be `int`. diff --git a/standard/lexical-structure.md b/standard/lexical-structure.md index e505878be..eeaaedcb4 100644 --- a/standard/lexical-structure.md +++ b/standard/lexical-structure.md @@ -1063,7 +1063,7 @@ unsigned_right_shift_assignment > *Note*: *right_shift* and *right_shift_assignment* are parser rules as they do not introduce a new token kind but represent a sequence of two tokens. Similarly, *unsigned_right_shift* and *unsigned_right_shift_assignment* are parser rules as they do not introduce a new token kind but represent a sequence of three tokens. The *operator_or_punctuator* rule exists for descriptive purposes only and is not used elsewhere in the grammar. *end note* -*right_shift* is made up of the two tokens `>` and `>`, and *unsigned_right_shift* is made up of the three tokens `>`, `>`, and `>`. Similarly, *right_shift_assignment* is made up of the two tokens `>` and `>=`, and *unsigned_right_shift_assignment* is made up of the three tokens `>`, `>`, and `>=`. Unlike other productions in the syntactic grammar, no characters of any kind (not even whitespace) are allowed between the two tokens in each of these productions. These productions are treated specially in order to enable the correct handling of *type_parameter_lists* ([§15.2.3](classes.md#1523-type-parameters)). +*right_shift* is made up of the two tokens `>` and `>`, and *unsigned_right_shift* is made up of the three tokens `>`, `>`, and `>`. Similarly, *right_shift_assignment* is made up of the two tokens `>` and `>=`, and *unsigned_right_shift_assignment* is made up of the three tokens `>`, `>`, and `>=`. Unlike other productions in the syntactic grammar, no characters of any kind (not even whitespace) are allowed between the tokens in any of these productions. These productions are treated specially in order to enable the correct handling of *type_parameter_lists* ([§15.2.3](classes.md#1523-type-parameters)). > *Note*: Prior to the addition of generics to C#, `>>` and `>>=` were both single tokens. However, the syntax for generics uses the `<` and `>` characters to delimit type parameters and type arguments. It is often desirable to use nested constructed types, such as `List>`. Rather than requiring the programmer to separate the `>` and `>` by a space, the definition of the two *operator_or_punctuator*s was changed. *end note*