scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Display error with full stack trace for crashed compiler

Open prolativ opened this issue 4 years ago • 5 comments

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)

prolativ avatar Nov 08 '21 10:11 prolativ

It can be related to: https://github.com/scalameta/metals/issues/3214

lwronski avatar Dec 07 '21 13:12 lwronski

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

romanowski avatar Mar 11 '22 09:03 romanowski

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

KacperFKorban avatar Mar 11 '22 11:03 KacperFKorban

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.

SethTisue avatar Sep 21 '22 17:09 SethTisue

I get something similar running a 3 line program as described here: https://github.com/VirtusLab/scala-cli/discussions/1420#discussioncomment-3807513

bblfish avatar Oct 05 '22 17:10 bblfish

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.

SethTisue avatar Oct 31 '23 01:10 SethTisue

Yay! Thank you!

SethTisue avatar Nov 18 '23 00:11 SethTisue

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.

SethTisue avatar Jan 24 '24 00:01 SethTisue