-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Error messages for wrong number of arguments are confusing #1458
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
Comments
Set owner to @sgmitrovic. |
NoSuchMethodException is now reporting a method with the same name but different arguments. |
This comment was originally written by [email protected] Can I take this one? |
This comment was originally written by [email protected] Actually, I have already started implementing the changes, just wanted to see if anyone had any objections to that. |
Jean-Rémi, no problem if you want to take a crack at it. There were quite a few changes recently about static warnings versus runtime errors, not sure if this particular message is impacted though. If it is please make sure that your implementation matches that. cc @gbracha. |
This comment was originally written by [email protected] Just want to post an update. I have been procrastinating to get this change made. My summer internship is draining me of my programming energy. I finally got down to spending a few hours on this toonight and I "fixed" the first case It now produces the following error message: [default@jr Debug_ia32]$ ./dart test.dart |
This looks good enough for me. Added Fixed label. |
This comment was originally written by [email protected] Just to clarify. Since I still haven't taken the time to adress all three sub-issues, I did not yet go through the process of creating a pull request or whichever other way external developers may offer patches. I am not 100% sure what "this" refers too, just wanted to try and makes things as clear as possible. |
case 1: case 2: case 3: |
This comment was originally written by [email protected] It looks like the updated check can behave incorrectly if a mixin presents: https://code.google.com/p/dart/issues/detail?id=9339 |
This issue was originally filed by [email protected]
This is clearly not a bug in the VM - but as a user it is a persistent source of confusion and I think that fixing this would help usability considerably.
These error messages are different for method calls, constructor calls and super constructor calls.
Here's a test program:
main() {
C o = new C(2);
o.m(1);
}
class Base {
Base();
}
class C extends Base {
C(var x): super(x); // call super construtor with wrong arg count
m(var x) => null;
}
As written, this produces the most confusing of the messages:
$ ../xcodebuild/Release_ia32/dart t.dart
'/Users/jimhug/dartfrog/dart/frog/t.dart': Error: line 16 pos 13: super class constructor 'Base.' not found
C(var x): super(x);
^
If that bug is fixed, but the original call to the constructor is changed to "C o = new C();" then the new message is:
$ ../xcodebuild/Release_ia32/dart t.dart
'/Users/jimhug/dartfrog/dart/frog/t.dart': Error: line 2 pos 9: invalid arguments passed to constructor 'C' for class 'C'
C o = new C();
^
This is the most useful of the messages - but the notion of "invalid arguments" is not clear. It would be very helpful if it specified an incorrect argument count and ideally something of the form, expected 1 argument but found 0.
If that bug is fixed, but the call to m is changed to "o.m()", then the new message is:
$ ../xcodebuild/Release_ia32/dart t.dart
Unhandled exception:
NoSuchMethodException - receiver: 'Instance of 'C'' function name: 'm' arguments: []]
0. Function: 'Object.noSuchMethod' url: 'bootstrap' line:623 col:3
1. Function: '::main' url: '/Users/jimhug/dartfrog/dart/frog/t.dart' line:3 col:6
I see how this one is the most difficult to change given the dart spec for NoSuchMethod handling. However, I find this surprising and confusing because it feels to me like there is a method 'm' defined on 'C' - however that method is simply not capable of responding to a message with zero arguments. Again, a message that specified incorrect argument count would be helpful and one that specified "expected 1 argument but found 0" would be most helpful.
The text was updated successfully, but these errors were encountered: