Skip to content

Flow analysis. In a do-while loop an assignment in while after break is dead code #60361

@sgrekhov

Description

@sgrekhov

UPD. Seems that according to the #42232 (comment) the below is not an issue but an expected behavior. Please confirm.

The code below produces no compile-time errors in either CFE or the analyzer.

main() {
  late int i;
  do {
    break;
  } while ((i = 42) < 0);
  i; // Definitely unassigned but no compile-time error
}

cc @stereotype441

Dart SDK version: 3.8.0-197.0.dev (dev) (Sat Mar 15 17:07:22 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/cfetype-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions