clarify leading infix example #19763
Replies: 3 comments
-
I think we want to exclude operator symbols (except prefix operators) from the tokens that can start an expression. The spec should make that clear. |
Beta Was this translation helpful? Give feedback.
-
Looking at the code in Scanner confirms this: def assumeStartsExpr(lexeme: TokenData) =
(canStartExprTokens.contains(lexeme.token) || lexeme.token == COLONeol)
&& (!lexeme.isOperator || nme.raw.isUnary(lexeme.name)) |
Beta Was this translation helpful? Give feedback.
-
The backticked identifier is a non-unary operator, so this is rejected:
https://github.com/scala/scala/blob/2.13.x/test/files/run/multiLineOps.scala If accepted, the OP would be
Scala 2 tries to closely approximate Scala 3 modulo indentation, but for some reason diverged on this point:
is OK but not
where it is trying to determine whether the backticked ident is an operator. Some ancient messaging that is not leading infix aware suggests adding a semicolon.
It disdains to suggest
I just spent too many minutes reading my code comment from 2021. For me, that was mid-pandemic and early funemployment, so it was a lot of brain fog ago. |
Beta Was this translation helpful? Give feedback.
-
started here: 4cc6c06#r138896963
the question is: in this example
why isn't the first instance of
???
considered to be a leading infix operator? it seems to satisfy all conditions mentioned in the documentation:Beta Was this translation helpful? Give feedback.
All reactions