Skip to content

[NNBD] Type promotion via flow analysis fails in nested loops #45360

Open
@nex3

Description

@nex3

The following code:

int foo(int? arg) {
  arg = 0;
  while (true) {
    while (true) {
      arg++;
    }
  }
}

produces this error:

  error • The method '+' can't be unconditionally invoked because the receiver can be 'null'. • test.dart:5:7 • unchecked_use_of_nullable_value

Despite the fact that arg is always provably non-null by the point the ++ happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NNBDIssues related to NNBD Releasearea-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).customer-dart-sass

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions