Skip to content

Analyzer crash when ! is applied to a null-shorting expression #43093

Closed
@stereotype441

Description

@stereotype441

The following code is accept without complaint by the VM but crashes the analyzer:

abstract class C {
  int? get x;
}

int f(bool b, C? c) {
  if (b) {
    return c?.x!;
  } else {
    return 0;
  }
}

main() {
  print(f(false, null));
}

I believe what is happening is that the analyzer gets confused about whether the ! should terminate null shorting (it should), and as a result break invariants of flow analysis; this in turn causes a crash when it tries to close the "then" branch of the "if" statement. I'm preparing a fix.

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