-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List of overloads shown on compiler error doesn't replace type parameters #12170
Comments
Two little concerns:
|
That's a good point. Maybe I can send a PR with everything I have in mind to improve these errors, instead of suggesting or tackling one thing at a time 😊 |
Actually this is unrelated to the other error message improvement... |
I agree with those concerns, but if we go with #11106 then it won't matter because you'll have a short summary explaining why each overload didn't match. |
Perhaps we could just enhance the current output to include the value of type parameters. For example like this:
This addresses the concerns mentioned in #12170 (comment) (which I share). I think I like 2) better despite being a bit more verbose, but it's probably not a big difference. |
I think in both cases you still have to do the replacement in your head. I just think that, even if it's more verbose, it's going to be clearer if type parameters are replaces. Maybe we can also check how other languages do this. |
Here's Java. This is the code: import java.util.*;
public class MyClass {
public static void main(String args[]) {
ArrayList<String> a = new ArrayList<String>();
a.add(1, 2, 3, 4);
}
} I get this error:
Note that "T" has been replaced. |
For what it's worth: In Java you don't have type unions, so the output is typically more concise. But you also often have longer namespaces which might balance that to some degree. |
Yeah, I just tried it with a union type and it doesn't look very good. |
I really think original compile error is better.
From my point of view, the issue is, we should improve 1's readability, as described in #11106 , it better. following is a really example come from avaram, a very small user table. After chang to wrong changes, i get error message like following: (please check screenshot) we know some of type is wrong, but, we have to find in below overload error msg, It Crazy. Even, if we can format the type art like this, it better.
|
Consider this code:
The error we get is this:
Note that the method is defined as
push(value : T)
and it shows up like that, but here the compiler knows thatT
isInt32
so it could tell the user that, instead of having them do the replacement.Ideally, the error should look like this:
The text was updated successfully, but these errors were encountered: