Skip to content

Parser does not allow ! before . (NNBD) #37111

@stereotype441

Description

@stereotype441

With --enable-experiment=non-nullable, the following code has a parse error:

class A {
  int? b = 1;
}
main() {
  var a = A();
  print(a!.b); // ERROR: Expected to find ')'
}

Note: I discovered this while trying to confirm whether we support ! in cascade expressions, e.g. a..foo()!.bar=3; (see discussion at dart-lang/language#293 (comment)). So we should double check this case too when fixing the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions