Function argument rejected based on faulty inferred parameter type #55644
Labels
analyzer-spec
Issues with the analyzer's implementation of the language spec
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P3
A lower priority bug or feature request
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Consider the following program:
The program is accepted with no compile-time errors and runs with no run-time errors with
dart
. The comments indicate the printouts during execution.However,
dart analyze
rejects the program with the following error messages (using tools from a fresh commit 6a25f12):Apparently, the behavior of the common front end is sound and useful. In particular, the inferred return type of a function literal is allowed to be a proper subtype of the chosen value for the 'imposed return type schema' which is taken from the context type, and the CFE does avoid (as it should) to leak the type variable
X
into the inferred value ofR
.On the other hand, the analyzer seems to leak an auxiliary type variable
Z0
into the value ofR
(Z0
is not in scope, it was presumably created during inference).Perhaps even more surprisingly, the spurious type variable
Z0
also arises when the actual argument is a functionfun
declared elsewhere (which means that its return type is declared explicitly, not inferred).So what's the correct behavior here, can we just say "everything is fine with the approach taken by the CFE"?
The text was updated successfully, but these errors were encountered: