Skip to content

Flow analysis. Second operand of for(;;) loop issueΒ #60089

@sgrekhov

Description

@sgrekhov

The following code works wihout issues in both CFE and the analyzer.

void test(Never n) {
  late int i;
  for (;n;) {
    i = 42; // No dead code warning here
  }
  i; // No error here
}

But i = 42 is dead code; there is no way to avoid executing the second operand of the for(;;) loop. Flow analysis should detect this, and i; should produce an error because i is definitely unassigned here.

Dart SDK version: 3.8.0-66.0.dev (dev) (Sun Feb 2 20:05:47 2025 -0800) on "windows_x64"

Metadata

Metadata

Assignees

Labels

P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesmodel-flowImplementation of flow analysis in analyzer/cfetype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions