-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#6218Description
These show that the compiler knows that a wildcard is not a valid identifier in accordance with the spec:
scala> def _ = 3
<console>:1: error: identifier expected but '_' found.
def _ = 3
^
scala> class _
<console>:1: error: identifier expected but '_' found.
class _
^
scala> val _ = 3
<console>:5: error: identifier expected but '_' found.
lazy val $result = _
^
<console>:10: error: identifier expected but '_' found.
+ "_: Int = " + scala.runtime.ScalaRunTime.replStringOf(_, 1000)
^However, scalac complains about multiple bindings to _ :
scala> { val _ = 3; val _ = 5; 7 }
<console>:8: error: _ is already defined as value _
{ val _ = 3; val _ = 5; 7 }
^This was reported on a mailing list a while ago (http://www.scala-lang.org/node/7159), but never filed as an issue. One improvement since then:
scala> { val _ = 3; `_` }
<console>:1: error: wildcard invalid as backquoted identifier
{ val _ = 3; `_` }
^