Skip to content

Conversation

@AlekseyTs
Copy link
Contributor

No description provided.

@AlekseyTs AlekseyTs requested review from 333fred and cston January 31, 2025 22:43
@AlekseyTs AlekseyTs requested a review from a team as a code owner January 31, 2025 22:43
@ghost ghost added the untriaged Issues and PRs which have not yet been triaged by a lead label Jan 31, 2025
@AlekseyTs
Copy link
Contributor Author

@333fred, @cston, @dotnet/roslyn-compiler Please review


this.CheckUnsafeModifier(declarationModifiers, diagnostics);

bool isIncrementDecrement = syntax is OperatorDeclarationSyntax { OperatorToken.RawKind: (int)SyntaxKind.PlusPlusToken or (int)SyntaxKind.MinusMinusToken };
Copy link
Member

@333fred 333fred Feb 4, 2025

Choose a reason for hiding this comment

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

Nit: this pattern is done 3 times in this file, consider extracting a helper. #Resolved

<value>User-defined operator '{0}' must be declared public</value>
</data>
<data name="ERR_BadIncrementOpArgs" xml:space="preserve">
<value>Overloaded instance increment operator '{0}' takes no parameters</value>
Copy link
Member

@333fred 333fred Feb 4, 2025

Choose a reason for hiding this comment

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

Consider using the imperative form here: must take no parameters, for example. Right now, it's unclear from the wording how many parameters are supposed to be present. #Resolved

{
Binder.CheckFeatureAvailability(syntax, MessageID.IDS_FeatureUserDefinedCompoundAssignmentOperators, diagnostics, ((OperatorDeclarationSyntax)syntax).OperatorToken.GetLocation());

if (parameterCount is not (0 or 2))
Copy link
Member

@333fred 333fred Feb 4, 2025

Choose a reason for hiding this comment

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

What's the reason for allowing 2 here? I would think that we should prefer giving errors about the specific operator the user typed out, rather than presuming the user meant to type a binary operator instead. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the reason for allowing 2 here? I would think that we should prefer giving errors about the specific operator the user typed out, rather than presuming the user meant to type a binary operator instead.

Parser reports an error for the 2 parameters case. I don't want to move all that parameter checking out of the parser, so I just made the smallest change to let "might be a success" cases through in the parser.

@AlekseyTs
Copy link
Contributor Author

@cston, @dotnet/roslyn-compiler For the second review

@AlekseyTs AlekseyTs merged commit 3d90c17 into dotnet:features/UserDefinedCompoundAssignment Feb 6, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Feature-UserDefinedCompoundAssignmentOperators untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants