-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closures parsed as self-type annotation #1683
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
Thanks for reporting @Blaisorblade . This is related to #1424. Unlike #1424, it seems the parser can do a better job here, as it's possible to know syntactically it's not a self-annotation, but a lambda def. |
Thanks I missed that! Also Martin there claims that handling this in Scalac is very tricky, so maybe it shouldn't be fixed. Making sure the grammar rejects this might be enough. |
I don't like that either. But "unbound" is probably too academic for some. How about
? |
I forgot to say: "Unbound Identifier" looks fine as a name for this class of error messages. But the explanation should say something else. |
I think we should not try to overengineer fixing this. The scalac code doing this is quite impenetrable. I think "not a legal self type clause" is perfectly fine as an error message. |
I was also concerned on unbound, I'll probably use "declaration" rather than "definition".
Agreed, especially since the grammar already excludes this (which I missed) and the current parser is already nontrivial. I'll close this as duplicate. |
I'm not sure I care and I can't conceive a use case (at least, not without involving some weird macro), but the following is valid for scalac and rejected (at parse-time) by dotty:
The reason is that dotty parses (what looks like) an expression, then sees
=>
and "reinterprets" the parsed expression as a self-type annotation.I'm not so concerned about the feature, I'm more concerned about aligning the grammar with the implementation.
I noticed this while trying to document errors for self-type annotations.
So this gives something like:
BTW I don't like "missing identifier", I think it's trying to say "unbound identifier" (I have a local patch I'll send at some point).
The text was updated successfully, but these errors were encountered: