Skip to content

[Version 11.0] Feature support for unsigned right shift operator#1595

Draft
RexJaeschke wants to merge 5 commits into
draft-v11from
v11-unsigned-right-shift-operator
Draft

[Version 11.0] Feature support for unsigned right shift operator#1595
RexJaeschke wants to merge 5 commits into
draft-v11from
v11-unsigned-right-shift-operator

Conversation

@RexJaeschke

Copy link
Copy Markdown
Contributor

This is Rex's adaptation of the corresponding MS proposal.

@RexJaeschke RexJaeschke added this to the C# 11 milestone Mar 6, 2026
@RexJaeschke RexJaeschke added type: feature This issue describes a new feature Review: pending Proposal is available for review labels Mar 6, 2026
@RexJaeschke RexJaeschke marked this pull request as draft March 6, 2026 15:46
Comment thread standard/expressions.md Outdated
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`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should nint and nuint be included here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. This is the integer-promotion rule; predefined >>> operators on nint/nuint (already listed) match directly when the operand is nint/nuint. Promotion targets stay int/uint/long/ulong because those cannot uniformly "fully represent" platform-sized nint/nuint. Text is consistent with the rule used for <</>>.

@BillWagner BillWagner force-pushed the v11-unsigned-right-shift-operator branch from e619ed7 to 1d55409 Compare April 29, 2026 19:48
@BillWagner BillWagner force-pushed the v11-unsigned-right-shift-operator branch from 1d7001e to cf99eec Compare May 13, 2026 16:36
@BillWagner BillWagner force-pushed the v11-unsigned-right-shift-operator branch from cf99eec to 69a738b Compare June 24, 2026 20:16
@BillWagner

Copy link
Copy Markdown
Member

An earlier version of this feature is already present on v11-alpha from a prior meeting. Edits made to this PR since then are not yet on v11-alpha; they will land at the next propagation. If you need them on v11-alpha sooner, please open a separate PR targeting v11-alpha.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review: pending Proposal is available for review type: feature This issue describes a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants