Skip to content

Flow analysis. Assignment in the third operand of for(;;) loop is not detected #60320

Open
@sgrekhov

Description

@sgrekhov

The code below produces an error in both CFE and the analyzer.

main() {
  int i;
  for (;; i = 42) {  }
  i; // Error: Non-nullable variable 'i' must be assigned before it can be used.
}

i is definitely assigned here. Yes, it is in dead code, but definitely assigned.

Dart SDK version: 3.8.0-174.0.dev (dev) (Mon Mar 10 21:06:07 2025 -0700) on "windows_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-flowImplementation of flow analysis in analyzer/cfe

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions