-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Objects ending with _
that have a body are parsed in a surprising way.
I only narrowed it down accidentally, but the symptoms were lots of compiler errors because of the defs I expected to be in the companion actually being at top level.
Compiler version
3.2.0
Minimized code
You can see how Hello_:
is defined instead, and x
is treated as a top-level definition
object Hello_:
def x = 1
object `Byte_`:
def x = 1
@main def hello =
println(Byte_)
println(Hello_:)
println(x)
Output
This parsing warning is the only indication that helped me figure out that something was off:
[warn] ./test.scala:2:3: Line is indented too far to the right, or a `{` or `:` is missing
[warn] def x = 1
[warn] ^
Expectation
The code either parses correctly, or fails to parse, or gives a meaningful warning
He-Pin