omit_local_variable_types reports a false positive for a coerced integer literal #57105
Labels
analyzer-linter
Issues with the analyzer's support for the linter package
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
linter-false-positive
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Consider the following program:
When
omit_local_variable_types
is enabled it reports that the type annotationdouble
is unnecessary.This is wrong because the value of the integer literal at run time is actually an instance of
double
, and if we change the context type to_
by removing the type annotation (and addingvar
orfinal
) then its value will be anint
, which may cause type errors below the declaration, and which is moreover an observable difference on some platforms at run time.The text was updated successfully, but these errors were encountered: