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 #59152

Closed
nex3 opened this issue May 22, 2023 · 4 comments · Fixed by dart-lang/linter#4542
Closed

Bogus unnecessary_this with pattern matching and shadowing #59152

nex3 opened this issue May 22, 2023 · 4 comments · Fixed by dart-lang/linter#4542
Assignees
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended P1 A high priority bug; for example, a single project is unusable or has many test failures 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
@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 #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.

@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?)

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive linter-set-recommended P1 A high priority bug; for example, a single project is unusable or has many test failures 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.

4 participants