Skip to content

Flow analysis. Variable of type Never in a for-in loop issue #60394

@sgrekhov

Description

@sgrekhov

There are two issues in the code below.

  1. No error in both CFE and the analyzer in test1
  2. No error in CFE in test2
test1() {
  late int i;
  if (2 > 1) {
    for (Never n in <dynamic>[i = 42]) {} // Analyzer warning "The value of the local variable 'n' isn't used."
  }
  i; // Definitely unassigned but no error in either CFE and the analyzer
}

test2(Never n) {
  late int i;
  if (2 > 1) {
    for (n in <dynamic>[i = 42]) {}
  }
  i; // Definitely unassigned. Error in the analyzer, no error in CFE
}

cc @stereotype441

Dart SDK version: 3.8.0-205.0.dev (dev) (Tue Mar 18 21:02:26 2025 -0700) on "windows_x64"

Metadata

Metadata

Assignees

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