Errors from compiler warnings don't make compilation process fail
Version(s) 1.8.1
Describe the bug Compilation errors originating from warnings do not fail the compilation process when compiling with bloop
To Reproduce
//> using scala 3.7.0
//> using options -Werror -Wunused:all
def foo =
val x = 1
2
scala-cli compile .
Expected behaviour
The exit code should NOT be 0.
The problem does not occur when compiling with --server=false
Huh... this can be observerd with Scala 2.13 and 2.12 (with -Xfatal-warnings) as well.
//> using scala 2.12
//> using options -Xfatal-warnings -Ywarn-unused:_
object Something {
def foo = {
val x = 1
2
}
}
and
//> using scala 2.13
//> using options -Werror -Wunused
object Something {
def foo = {
val x = 1
2
}
}
What's interesting, this still fails when we try to run... but we don't run with Bloop, we just build with it.
As far as I can tell, we're getting status code 0 from Bloop's buildTargetCompile endpoint, so Bloop claims everything is fine.
https://github.com/VirtusLab/scala-cli/blob/815fb5d4c1bc29023a5e09159d55f82bb2bf720e/modules/build/src/main/scala/scala/build/Bloop.scala#L53-L57
I'd say need to investigate upstream. cc @tgodzik
Added integration tests with the reproduction for all Scala versions in this draft PR:
- https://github.com/VirtusLab/scala-cli/pull/3736
I think the issue might be that in Bloop we remove the flag, and later turn all warnings to errors manually. This is to always get proper artefacts for Metals etc. generated.
just found this caveat 😅
Is there another way to find out if a scala-cli compile / package had warnings, other than parsing STDERR?
Is there another way to find out if a
scala-cli compile/packagehad warnings, other than parsing STDERR?
...not really.