-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Incorrect error message #34492
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
I agree that the quality of the error message is bad. Out of curiosity, is there any reason for this behavior? It breaks the equivalence with: main() {
var x = int;
x.toString();
} for no reason that I can see, and it's not preventing me from doing anything because |
I believe the original motivation was that it's confusing to have the clash where I suspect that the rules are sufficient to justify that we won't evaluate In any case, it's a pure opinion in the spec, not a technical necessity. [Edit: Just discussed this with @kmillikin IRL and discovered that we should simply delete the sentence in the spec about "immediately followed by |
On rereading it, I can't make I'm also having trouble understanding how static invocation works at all. Say we've got First problem: the static type of Second problem: we look up the method I believe that things could be vastly simplified by saying that |
I should add: if we could pull off the change I suggest then the spec would match the implementation. We would then not need a special case to make |
I thought it would work, but I walked through it (sections 16.14.5, 16.19, 16.19.3, 16.18.1) and concluded that we will accept
just like you said. I also agree that we should try to introduce the notion of a static invocation whose syntactic form can also be like an ordinary method invocation, and then |
Created dart-lang/language#3759 in order to improve the specification as indicated. |
This may well be considered low priority, but checking up on the status of #26024 I noted that the vm and dart2js both report an error containing the words
Method not found: 'int.toString'
for the following program:It is correct to make it an error (see here), but the wording seems to imply that there was a static lookup for a class method (aka static method) named
toString
inint
, and that lookup failed, but the error is actually that it is specified separately that it is a compile-time error to invoke an instance method declared byObject
on a type literal:So the error message ought to be something like
Error: Invoking instance method on type literal
.A similar issue arises for getters:
The requirement that a period must follow the type literal is there in order to allow
(int).toString()
and(int).hashCode
, if needed. ;-)The text was updated successfully, but these errors were encountered: