Skip to content

incorrect definitely unassigned error with late #42301

@a14n

Description

@a14n

Although it looks correct the following code triggers an error :

The late local variable 'i' is definitely unassigned at this point - line 11

main() {
  late int i;
  bool b = true;
  while(true) {
    switch (b) {
      case true:
        i = 1;
        b = false;
        break;
      case false:
        print(i);
        return;
    }
  }
}

Tested on https://nullsafety.dartpad.dev/ (Based on Dart SDK 2.9.0-edge.2ed302bfbbbad1d10f6c839c504ae3871fc96dc2)

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD Releaselegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions