Skip to content

CFE does not promote property accesses on LHS of ??. #56874

@stereotype441

Description

@stereotype441

The following code is accepted by the analyzer but rejected by the CFE:

class C {
  final int? _property;
  C(this._property);
}
int test(C c) {
  c._property ?? (throw '');
  return c._property;
}
main() {}

The CFE reports this error:

test.dart:7:12: Error: A value of type 'int?' can't be returned from a function with return type 'int' because 'int?' is nullable and 'int' isn't.
  return c._property;
           ^

I'm working on a fix.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions