scala-cli
scala-cli copied to clipboard
Display error with full stack trace for crashed compiler
If the compiler crashes during compilation the full stack trace from the compiler (and maybe some additional clarification) should be displayed instead of the sole error message from the compiler's exception, which can be as vague as e.g. just assertion failed: <none>.
This is important for 2 main reasons:
- It's not quite clear if the error means something is wrong with the user's code, the compiler or scala-cli itself
- This would make reporting errors to the compiler easier and would encourage people to report bugs (we could also include some message explaining how to do that with a link to the proper repository etc.)
(Reported for scala-cli v0.0.7)
It can be related to: https://github.com/scalameta/metals/issues/3214
I think we should also expand this issue to all cases where the compiler prints information, e.g. when users want to print trees after certain phases. cc @KacperFKorban
The three major use cases related to this issue are:
- output from Scala 2 compiler e.g.
-Xprint:typer(in Scala 3 this output goes through reporter, so it works) - output from macros
- output from compiler plugins
Another use case is compiler crashes. With scala-cli compile I just get e.g.
exception occurred while compiling /Users/tisue/tmp/20220921/S.scala
Error compiling project (Scala 3.2.0, JVM)
Error: Unexpected error when compiling project_40de3a9abc_40de3a9abc: 'assertion failed: Bad superClass for class Integer: val <none>'
Compilation failed
whereas with 3.2.0's scalac I get the full stack trace — which I need, if I'm going to file a bug report, or attempt to investigate the crash myself.
I get something similar running a 3 line program as described here: https://github.com/VirtusLab/scala-cli/discussions/1420#discussioncomment-3807513
Note (as @lwronski pointed out on #1420) that one can work around this with --server=false — I guess because it's bloop that's eating the additional output from the compiler.
This came up for me today in one of the scenarios already mentioned by @KacperFKorban : I am debugging a Scala 3 compiler plugin, and the debugging output from the plugin vanishes. --server=false makes the output appear as expected.
Yay! Thank you!
I am debugging a Scala 3 compiler plugin, and the debugging output from the plugin vanishes. --server=false makes the output appear as expected.
This isn't fixed, but I guess it's part of #2530.