Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field-backed properties: report diagnostic for variable named field declared in accessor #76671

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cston
Copy link
Member

@cston cston commented Jan 8, 2025

Report an error for a declaration of a local or parameter named field within an accessor, since field will not bind to that variable. See item 2 in #76031.

Based on the variable declaration checks reverted in #74164.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 8, 2025
@cston cston force-pushed the variable-named-field branch from 0ada606 to b40643e Compare January 9, 2025 00:58
@@ -6886,8 +6886,11 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_FieldIsAmbiguous_Title" xml:space="preserve">
<value>The 'field' keyword binds to a synthesized backing field for the property.</value>
</data>
<data name="INF_IdentifierConflictWithContextualKeyword_Title" xml:space="preserve">
Copy link
Member Author

Choose a reason for hiding this comment

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

INF_IdentifierConflictWithContextualKeyword_Title

Unused.

@cston cston marked this pull request as ready for review January 9, 2025 01:07
@cston cston requested a review from a team as a code owner January 9, 2025 01:07
@RikkiGibson RikkiGibson self-assigned this Jan 9, 2025
@cston cston force-pushed the variable-named-field branch from ca99664 to e89a75b Compare January 9, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Field Keyword 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.

2 participants