VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
545 stars 127 forks source link

Compiler output passed wrongly from Bloop #1023

Open prolativ opened 2 years ago

prolativ commented 2 years ago

Version(s)

0.1.4, 0.1.5, possibly earlier ones as well

Describe the bug

Compiler options passed after -O seem to be ignored when compiling with scala 2

To Reproduce

Foo.scala:

trait Foo

Running

scala-cli compile -S 2.13.8 -O -Vprint:typer Foo.scala

prints just

Compiling project (Scala 2.13.8, JVM)
Compiled project (Scala 2.13.8, JVM)

Expected behaviour Compiler option passed in the command line after -O should be correctly passed to the compiler.

In the example above this should print the program tree after the typer phase similarly to

sdk use scala 2.13.8
scalac -Vprint:typer Foo.scala

printing

[[syntax trees at end of                     typer]] // Foo.scala
package <empty> {
  abstract trait Foo extends scala.AnyRef
}
lwronski commented 2 years ago

Hi @prolativ, Thanks for reporting, it seems that is bloop issue that output from scalac is not properly handled.

There is exists a workaround and you have to use plain scalac without bloop. To disable using bloop you should use --server=false flag.

$ scala-cli compile -S 2.13.8 -O -Vprint:typer Foo.scala --server=false
[[syntax trees at end of                     typer]] // Foo.scala
package <empty> {
  abstract trait Foo extends scala.AnyRef
}
SethTisue commented 7 months ago

Could this be considered a blocker for promoting scala-cli to be scala? I feel (rather strongly) that it should be.

tgodzik commented 7 months ago

Makes sense, I will need to take a look at it.

tgodzik commented 3 months ago

Fixing it in https://github.com/scalacenter/bloop/pull/2361

tgodzik commented 3 months ago

@SethTisue do you know if the output from "-Vprint" is being printed only to standard output? This might not be possible to sensibly fix as we would need to forward Bloop stdout and that could bring in more than we wanted, since it is running multiple compilations.

SethTisue commented 3 months ago

where else would or could it be printed?

tgodzik commented 2 months ago

where else would or could it be printed?

I was thinking that it could go via info diagnostics for example? Since, I guess there is no sensible way to pass a custom output stream to the compiler