-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Better disambiguation of leading operators #11376
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
Conversation
@@ -2,8 +2,7 @@ | |||
val a = 5 | |||
val x = 1 | |||
|
|||
+ // | |||
`a` * 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is interesting. It worked somewhat by accident before. First, if the backticked "`a`" gets changed to "a" this never compiles. We do not skip a newline after a prefix operator, so we have a prefix operator +
with nothing that follows it --> error. What happened previously was that the "`a`" was interpreted as a leading infix operator, so the lexical analyzer saw a noun +
, followed by an operator "`a`", and did not insert a new line. Then the parser made different sense of it and reclassified +
to a prefix operator and "`a`" to its operand. But now we do not interpret "`a`" as a leading operator anymore, so we get an error (as we should).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I've also plaid a bit this with scala 2 and can't compile it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. I stared at that test while bringing -Xsource:3
into better alignment. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Classify something as a leading operator only if it is not followed in turn
by an operator. This means that
the
i'
is no longer classified as a leading operator.