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

[analyzer] ignore 'dead_code' for this line action misplaces the ignore: dead_code comment. #54565

Open
modulovalue opened this issue Jan 10, 2024 · 0 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@modulovalue
Copy link
Contributor

Consider:

void main() {
  MapEntry(
    throw 0,
    2,
  );
}

Notice that, as expected, the second argument to the MapEntry constructor invocation is being reported as dead code.

To reproduce:

  1. Move the caret to the line containing the 2.
  2. Invoke the "ignore 'dead_code' for this line" action.
  3. Notice how the // ignore: dead_code line will be placed in a position that does not have the intended effect. It will be placed between void main() { and MapEntry( and not between throw 0, and 2,.
Screenshot 2024-01-10 at 14 43 24

I expected the ignore 'dead_code' for this line action to place the comment in a position that causes the dead code warning to be disabled, that is:

Screenshot 2024-01-10 at 14 43 42
@mit-mit mit-mit added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 10, 2024
@pq pq added analyzer-warning Issues with the analyzer's Warning codes P3 A lower priority bug or feature request labels Jan 11, 2024
@keertip keertip added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 15, 2024
@srawlins srawlins added analyzer-quick-fix and removed analyzer-warning Issues with the analyzer's Warning codes labels Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants