Skip to content

Update field keyword breaking change diagnostics #76031

@cston

Description

@cston

With -langversion:preview, the token field, when used as a primary expression in a property accessor, binds to the synthesized backing field for the property. That is a breaking change when there is another symbol in scope named field that the compiler would have bound to with earlier language versions. The compiler reports a warning in -langversion:preview for those cases.

A couple of issues have been reported regarding the current warning:

  1. The warning does not match the Breaking change warnings proposal. In that proposal, warnings are reported in earlier language versions that the behavior will change rather than warning in later language versions that behavior has changed.

  2. The warning is reported for a reference to field, but not for a declaration of a local or parameter named field within the accessor, even though field will not bind to that variable. (To bind to the variable, use @field.)

We should consider updating the diagnostics to address these issues.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions