You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
voidmain() {
voidFunction(int) f = (() =>42) asvoidFunction(int);
}
generates an error:
type '() => int' is not a subtype of type '(int) => void' in type cast
I think it would be better if the error message used Dart's normal syntax for Function types. That is, I think the error message would be better as:
type 'int Function()' is not a subtype of type 'void Function(int)` in type cast.
Note that the analyzer already does that. If I remove the cast, the analyzer reports:
A value of type 'void Function()' can't be
assigned to a variable of type 'void Function(int)'. Try changing
the type of the variable, or casting the right-hand type to 'void
Function(int)'. • invalid_assignment
(The example above is contrived (people should not be performing explicit casts on Function objects in practice), but that form of error is encountered in the wild (often with a combination of generic classes, callbacks, and accidentally omitted type parameters).)
The text was updated successfully, but these errors were encountered:
keertip
added
the
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
label
Apr 18, 2022
Running the code:
generates an error:
I think it would be better if the error message used Dart's normal syntax for
Function
types. That is, I think the error message would be better as:Note that the analyzer already does that. If I remove the cast, the analyzer reports:
(The example above is contrived (people should not be performing explicit casts on
Function
objects in practice), but that form of error is encountered in the wild (often with a combination of generic classes, callbacks, and accidentally omitted type parameters).)The text was updated successfully, but these errors were encountered: