Skip to content

[Wildcard Variables] implement THIS_ACCESS_FROM_FIELD_INITIALIZER #56442

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

Closed
Tracked by #55680
pq opened this issue Aug 12, 2024 · 2 comments
Closed
Tracked by #55680

[Wildcard Variables] implement THIS_ACCESS_FROM_FIELD_INITIALIZER #56442

pq opened this issue Aug 12, 2024 · 2 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec feature-wildcard-variables Implementation of the wildcard variables feature P1 A high priority bug; for example, a single project is unusable or has many test failures triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Aug 12, 2024

The front-end has this error:

ThisAccessInFieldInitializer:
  problemMessage: "Can't access 'this' in a field initializer to read '#name'."
  analyzerCode: THIS_ACCESS_FROM_FIELD_INITIALIZER

that names THIS_ACCESS_FROM_FIELD_INITIALIZER (which doesn't exist).

That said, we do have IMPLICIT_THIS_REFERENCE_IN_INITIALIZER.

@kallentu: any reason we need a new error code here and can't use IMPLICIT_THIS_REFERENCE_IN_INITIALIZER?

Here's the relevant part of the spec:

https://github.com/dart-lang/language/blob/main/working/wildcards/feature-specification.md#initializing-formals

A corresponding (failing) test:

https://dart-ci.appspot.com/log/any/analyzer-asserts-linux/25960/language/wildcard_variables/initializing_formal_parameters/this_initializer_access_error_test

(There are co19 ones too.)

@dart-github-bot
Copy link
Collaborator

Summary: The issue requests the implementation of the THIS_ACCESS_FROM_FIELD_INITIALIZER lint rule, which would flag instances of accessing this within field initializers, potentially leading to unexpected behavior.

@dart-github-bot dart-github-bot added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Aug 12, 2024
@pq pq self-assigned this Aug 12, 2024
@pq pq added feature-wildcard-variables Implementation of the wildcard variables feature dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec P1 A high priority bug; for example, a single project is unusable or has many test failures labels Aug 12, 2024
@pq
Copy link
Member Author

pq commented Aug 12, 2024

Ok, after a nice ling chat w/ @stereotype441, I think I see what's happening.

TL;DR THIS_ACCESS_FROM_FIELD_INITIALIZER is likely a stale reference to an analyzer error code that existing pre CFE.

I'll loop back and do some cleanup but for now this whole issue is a bit of a red herring so I'll close it out.

Sorry for the noise!

@pq pq closed this as completed Aug 12, 2024
copybara-service bot pushed a commit that referenced this issue Aug 19, 2024
… reference

See: #56442

Change-Id: Ifa931c56fe710317d3bbf995f8354ca488711735
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380884
Auto-Submit: Phil Quitslund <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Johnni Winther <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec feature-wildcard-variables Implementation of the wildcard variables feature P1 A high priority bug; for example, a single project is unusable or has many test failures triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants