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

Bogus unnecessary_this with pattern matching and shadowing #4381

Closed
nex3 opened this issue May 22, 2023 · 4 comments · Fixed by #4542
Closed

Bogus unnecessary_this with pattern matching and shadowing #4381

nex3 opened this issue May 22, 2023 · 4 comments · Fixed by #4542
Assignees
Labels
false-positive P1 A high priority bug; for example, a single project is unusable or has many test failures set-recommended Affects a rule in the recommended Dart rule set type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@nex3
Copy link
Member

nex3 commented May 22, 2023

For the code below:

class Foo {
  Object? value;

  bool equals(Object other) => switch (other) {
    Foo(: var value) => this.value == value,
    _ => false
  };
}

the 3.0.0 analyzer will print

info - test.dart:5:25 - Unnecessary 'this.' qualifier. Try removing 'this.'. - unnecessary_this

This is incorrect. The this. is necessary to disambiguate the containing class's value field from the value variable bound by the switch expression.

@srawlins srawlins transferred this issue from dart-lang/sdk May 23, 2023
@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels May 23, 2023
@github-actions github-actions bot added set-recommended Affects a rule in the recommended Dart rule set labels May 23, 2023
@pq pq added P1 A high priority bug; for example, a single project is unusable or has many test failures and removed P3 A lower priority bug or feature request labels May 23, 2023
@pq pq self-assigned this May 23, 2023
@pq
Copy link
Member

pq commented May 23, 2023

Good catch. Taking a look now. Thanks!

@pq
Copy link
Member

pq commented May 23, 2023

It looks like the issue is percolating up from analyzer.

Tracking in dart-lang/sdk#52486

@nex3
Copy link
Member Author

nex3 commented Aug 2, 2023

@pq Is there an ETA on this ending up in a released Dart version? It looks like Dart 3.0.7 is still surfacing the bogus lint.

nex3 added a commit to sass/dart-sass that referenced this issue Aug 2, 2023
nex3 added a commit to sass/dart-sass that referenced this issue Aug 2, 2023
@pq
Copy link
Member

pq commented Aug 3, 2023

My understanding is that a Dart 3.1 release is slated for the next few weeks. (@itsjustkevin could confirm?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive P1 A high priority bug; for example, a single project is unusable or has many test failures set-recommended Affects a rule in the recommended Dart rule set type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants