Wrong flow analysis after non-nulable type and ==null
#60114
Labels
area-dart-model
For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.
model-flow
Implementation of flow analysis in analyzer/cfe
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
The following code works well and produces no errors in both CFE and the analyzer.
But according to the flow analysis specification:
According to the above, the body of
if (s == null) ...
is unreachable and therefore initialization ofi
occurs in a dead code. This leavesi
definitely unassigned and thereforei;
should be a compile-time error.Probably this happens because
s == null
is not alwaysfalse
in an unsound mode, but there are no mentions of unsound mode in the flow analysis spec.cc @johnniwinther
Dart SDK version: 3.8.0-73.0.dev (dev) (Thu Feb 6 20:02:31 2025 -0800) on "windows_x64"
The text was updated successfully, but these errors were encountered: