Description
Here's an error I came across recently:
Where the code is a tearOff:
Class(providerFactory: AnotherClass.new)
It goes to say that this error message is pretty much useless due to how much information overload there is.
The root of the issue IMO is: For Functions/Records, just logging the entire type isn't enough.
I think it would be massively helpful if:
- The type was formatted to span over multiple lines (by respecting dart_style!)
- Whatever causes the assignment error should be highlighted using
diff
or some special colour
Here's an example of what I think
Consider:
void fn(int a, {String? b, required int c, double? d, bool? e}) {}
void Function(
int a, {
String? b,
int? c,
double? d,
bool? e,
Object? f,
}) cb = fn;
The current error message is:
A value of type 'void Function(int, {String? b, int? c, double? d, bool? e})' can't be assigned to a variable of type 'void Function(int, {String? b, int c, double? d, bool? e, Object? f})'.
Try changing the type of the variable, or casting the right-hand type to 'void Function(int, {String? b, int c, double? d, bool? e, Object? f})'
I think it'd be more more readable if we instead had:
Invalid assignment error.
Expected:
void Function(int a, {String? b, int? c, double? d, bool? e})
But got:
void Function(
int a, {
String? b,
required int c,
double? d,
bool? e,
Object? f,
})
Where the difference is:
void Function(
int a, {
String? b,
- int? c,
+ required int c,
double? d,
bool? e,
+ Object? f,
})