dart-lang / co19

A Dart language and library conformance test suite
BSD 3-Clause "New" or "Revised" License
37 stars 28 forks source link

co19/LanguageFeatures/nnbd/static_errors_A14_t08 #564

Closed scheglov closed 4 years ago

scheglov commented 4 years ago

See also https://github.com/dart-lang/sdk/issues/39865 and https://github.com/dart-lang/sdk/issues/40088 I will keep the issue for the analyzer open for now, because I don't remember this code, and don't know if we do such promotion intentionally.

I believe that warnings are correct. After a = new A() the variable a is promoted from A? to A. So, null checking on it is a warning.

--- Command "dart2analyzer" (took 18ms):
DART_CONFIGURATION=ReleaseX64NNBD out/ReleaseX64NNBD/dart-sdk/bin/dartanalyzer --enable-experiment=non-nullable --ignore-unrecognized-flags --packages=/b/s/w/ir/cache/builder/sdk/.packages --format=machine --no-hints /b/s/w/ir/cache/builder/sdk/tests/co19/src/LanguageFeatures/nnbd/static_errors_A14_t08.dart

exit code:
0

stderr:
WARNING|STATIC_WARNING|INVALID_NULL_AWARE_OPERATOR|/b/s/w/ir/cache/builder/sdk/tests/co19/src/LanguageFeatures/nnbd/static_errors_A14_t08.dart|33|4|3|The target expression can't be null, so the null-aware operator '?.[' can't be used.
WARNING|STATIC_WARNING|INVALID_NULL_AWARE_OPERATOR|/b/s/w/ir/cache/builder/sdk/tests/co19/src/LanguageFeatures/nnbd/static_errors_A14_t08.dart|31|4|2|The target expression can't be null, so the null-aware operator '?.' can't be used.
WARNING|STATIC_WARNING|INVALID_NULL_AWARE_OPERATOR|/b/s/w/ir/cache/builder/sdk/tests/co19/src/LanguageFeatures/nnbd/static_errors_A14_t08.dart|32|5|3|The target expression can't be null, so the null-aware operator '?..' can't be used.

--- Re-run this test:
python tools/test.py -n analyzer-asserts-strong-linux co19/LanguageFeatures/nnbd/static_errors_A14_t08
scheglov commented 4 years ago

The spec for flow analysis, look for "promotable via assignment".

sgrekhov commented 4 years ago

The spec for flow analysis, look for "promotable via assignment".

Thank you!