Skip to content

Testing an assignment against null does not promote the assigned variable (unchecked_use_of_nullable_value) #2583

Closed
@Hixie

Description

@Hixie
int? test() => null;

void main() {
  int? foo;
  while ((foo = test()) != null) {
    foo.toDouble(); // error • The method 'toDouble' can't be unconditionally invoked because the receiver can be 'null'
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    flow-analysisDiscussions about possible future improvements to flow analysissmall-featureA small feature which is relatively cheap to implement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions