scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

Compiler "hangs" for 1+ minutes on a one line input. #9344

Closed sir-wabbit closed 3 years ago

sir-wabbit commented 4 years ago

Found an example that takes "forever" (1-2 minutes) to compile (with an error!)

Minimized code

// TD-184aaea3a529ccf09be73fa770e0aba21f73983c
val I1: Int = 0 * * * 8 * 1 - 1 + 1 +

Output

sbt:dotty> dotc test.scala
[warn] Multiple main classes detected.  Run 'show discoveredMainClasses' to see the list
[info] running (fork) dotty.tools.dotc.Main -classpath /Users/akonovalov/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.3/scala-library-2.13.3.jar:/Users/akonovalov/Documents/projects/dotty-fork/library/../out/bootstrap/dotty-library-bootstrapped/scala-0.26/dotty-library_0.26-0.26.0-bin-SNAPSHOT.jar test.scala
-- Error: test.scala:1:32 ------------------------------------------------------
1 |val I1: Int = 0 * * * 8 * 1 - 1 + 1 +
  |              ^^^^^^^^^^^^^^^^^^^^^
  |postfix operator `+` needs to be enabled
  |by making the implicit value scala.language.postfixOps visible.
  |----
  |This can be achieved by adding the import clause 'import scala.language.postfixOps'
  |or by setting the compiler option -language:postfixOps.
  |See the Scaladoc for value scala.language.postfixOps for a discussion
  |why the feature needs to be explicitly enabled.
1 error found
[error] Nonzero exit code returned from runner: 1
[error] (dotty-compiler / Compile / runMain) Nonzero exit code returned from runner: 1
[error] Total time: 119 s (01:59), completed Jul 10, 2020 9:27:33 PM

Expectation

Shouldn't take THAT long to finish.

odersky commented 3 years ago

I now see 22 seconds, which is not too outrageously bad given the crazy input.