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

Wrong dead code analysis on records with bool #56222

Closed
ChaserVasya opened this issue Jul 11, 2024 · 2 comments
Closed

Wrong dead code analysis on records with bool #56222

ChaserVasya opened this issue Jul 11, 2024 · 2 comments
Assignees
Labels
analyzer-ux analyzer-warning Issues with the analyzer's Warning codes 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

@ChaserVasya
Copy link

Snippet

void main() {
  const boolContainer = (b: true);
  if (true || boolContainer.b) {}
}

Problem

{} is recognized as dead code. It is wrong
Снимок экрана 2024-07-11 в 13 08 53

dart info

  • Dart 3.2.3 (stable) (Tue Dec 5 17:58:33 2023 +0000) on "macos_arm64"
  • on macos / Version 14.5 (Build 23F79)
  • locale is ru-RU
@ChaserVasya ChaserVasya changed the title Wrong dead code analysis on pattern with bool Wrong dead code analysis on records with bool Jul 11, 2024
@dart-github-bot
Copy link
Collaborator

Summary: The Dart analyzer incorrectly identifies code within the if statement as dead code when the condition is always true due to a record with a boolean field. This leads to a false positive warning.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 11, 2024
@srawlins
Copy link
Member

Yeah the highlight range seems to include the { and anything else to the right, on the line with {. Bad range.

@srawlins srawlins added analyzer-warning Issues with the analyzer's Warning codes analyzer-ux labels Jul 11, 2024
@keertip keertip added the P3 A lower priority bug or feature request label Jul 11, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
@srawlins srawlins self-assigned this Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-ux analyzer-warning Issues with the analyzer's Warning codes 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