Analyzer error message on incompatible functions is very confusing #23492
Labels
legacy-area-analyzer
Use area-devexp instead.
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Running the analyzer (version 1.11.0-dev.0.0) on the attached file produces the following very confusing error message:
leafp@leafp-linux:~/src/dev_compiler$ dartanalyzer ~/tmp/function-warning.dart
Analyzing [/usr/local/google/home/leafp/tmp/function-warning.dart]...
[warning] A value of type 'Function2 (/usr/local/google/home/leafp/tmp/function-warning.dart)' cannot be assigned to a variable of type 'Function2 (/usr/local/google/home/leafp/tmp/function-warning.dart)' (/usr/local/google/home/leafp/tmp/function-warning.dart, line 12, col 27)
[hint] The value of the local variable 'a2b' is not used (/usr/local/google/home/leafp/tmp/function-warning.dart, line 12, col 21)
1 warning found.
Neither typedef instantiation gets printed out with its arguments, so the error message basically says "Function2 cannot be assigned to Function2", which is fairly confusing. I would expect an error message that looked something like "Function2<int, double> cannot be assigned to a variable of type Function2<A, B>".
Attachment:
function-warning.dart (312 Bytes)
The text was updated successfully, but these errors were encountered: