Skip to content

[NNBD] No compile error in CFE to read non-initialized nullable variable in spread operator #43495

@sgrekhov

Description

@sgrekhov

The following code produces a compile error in analyzer and only runtime error in VM

main() {
  List? x2;
  Set? x3;
  Iterable? x4;

  Set res;

  res = {...x2}; // Analyzer error - An expression whose value can be 'null' must be null-checked before it can be dereferenced.
  res = {...x2}; // Analyzer error - An expression whose value can be 'null' must be null-checked before it can be dereferenced.
  res = {...x2}; // Analyzer error - An expression whose value can be 'null' must be null-checked before it can be dereferenced.
}

There must be compile error in CFE as well
Dart SDK version: 2.10.0-110.0.dev (dev) (Wed Sep 9 17:51:43 2020 -0700) on "windows_x64"

Metadata

Metadata

Labels

NNBDIssues related to NNBD Releaselegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions