Skip to content

Analyzer error message on incompatible functions is very confusing #23492

Closed
@leafpetersen

Description

@leafpetersen

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions