scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

A new contender for the title of Shortest Compiler Slayer #10731

Closed hobwekiva closed 6 years ago

hobwekiva commented 6 years ago
val eq.a=1

Found thanks to @emilypi (most credit goes to her)

Tested in 2.13.0-M3 REPL

som-snytt commented 6 years ago

That's a good one, but there are some caveats that figure into how the judges score the routine.

The shortest crasher has to be a compilation unit, not a snippet. Yes, that's a high bar.

Also, points are deducted for crashes landing in RefChecks, which are less highly esteemed than actual typechecking bugs.

Leaking erroneous trees has a long and storied history, e.g., https://github.com/scala/bug/issues/4425, reported by propensive, who happens to hold the shortest crasher title.

Just as they added ice dancing and synchronized swimming to the Olympics, scala center might be persuaded to award the fastest crasher, as measured by the new compiler statistics. That would probably happen in parser, however. Crashes in linting are strictly disallowed as they are not a true compiler sport, much like a gold medal in baseball or tennis.

Error recovery is challenging for a compiler, but scalac feels so bad about telling you that your program can't work, it prefers to procrastinate about giving you the bad news. In some cases, the compiler will just go on compiling for hours rather than see the look on your face when it can't find an implicit and you have no idea what import is missing.

som-snytt commented 6 years ago

I did just receive a certificate from scala center for shortest fix for a short compiler slayer.

I was hoping for a coupon at the scala store...

SethTisue commented 6 years ago

PR: https://github.com/scala/scala/pull/6334

SethTisue commented 6 years ago

I've seen it asked several times now if this is valid syntax. it is; it's a pattern match. demonstration:

Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_162).
Type in expressions for evaluation. Or try :help.

scala> object a { val b = 3 }
defined object a

scala> val a.b = 4
scala.MatchError: 4 (of class java.lang.Integer)
  ... 28 elided

scala> val a.b = 3
lrytz commented 6 years ago

Fixed in https://github.com/scala/scala/pull/6273