Open
Description
Create a file containing the following (invalid) code:
void f(String? s) {
s?.[0];
}
The use of ?.
before an index operator appears to no longer be supported, but the diagnostic message is very confusing. There is only one message generated (on the reference to s
inside the body):
error: An expression whose value can be 'null' must be null-checked before it can be dereferenced. (unchecked_use_of_nullable_value at [nnbd_test_package] lib/test.dart:2)
The message should explain to users that they can't use ?.
before []
to null-check s
.
Metadata
Metadata
Assignees
Labels
A lower priority bug or feature requestFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.Contributions welcome to help resolve this (the resolution is expected to be clear from the issue)Error recovery in analyzer/CFE.Incorrect behavior (everything from a crash to more subtle misbehavior)