Incorrect constant evaluation of lists declared in another file #35230
Labels
legacy-area-analyzer
Use area-devexp instead.
P1
A high priority bug; for example, a single project is unusable or has many test failures
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Consider the following code:
lib.dart
:main.dart
:If the analysis driver visits
main.dart
first, then it evaluates the constantx
as having the value<dynamic>['a']
, and the constanty
as having the value<String>['b']
. This is incorrect--both lists should have type argument<String>
. As a result, the errorINCONSISTENT_CASE_EXPRESSION_TYPES
is reportend.Note that the type that is incorrect is the type of the constant value, not the static type of the constant declaration. Replacing
const x = ...
withconst List<String>x = ...
in the code above is not sufficient to work around the bug.It's also possible to get inconsistencies between two constants declared in the same file, if one of the constants is referred to by another file, and the analysis driver visits that other file first.
The text was updated successfully, but these errors were encountered: