-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Compiler version
Scala compiler version 3.1.0 -- Copyright 2002-2021, LAMP/EPFL
Minimized example
Calling scalac with -Xfatal-warnings
set multiple times results in compilation error
CompilerTests % scalac -version
Scala compiler version 3.1.0 -- Copyright 2002-2021, LAMP/EPFL
CompilerTests % scalac -Xfatal-warnings -Xfatal-warnings some.scala; echo $?
Flag -Werror set repeatedly
1 error found
1
Expectation
It could stay as warning or silently ignored as in Scala 2
CompilerTests % scalac -version
Scala compiler version 2.13.7 -- Copyright 2002-2021, LAMP/EPFL and Lightbend, Inc.
CompilerTests % scalac -Xfatal-warnings -Xfatal-warnings some.scala; echo $?
0
Explanation
If you have sbt build, where multiple plugins are used for setting some compiler settings (like tpolecat and another one private maintained by the company) they may set the same option multiple times. It was safe before, but now such builds will fail if -Xfatal-warnings
is used.
There is a workaround like use ~=
op in sbt and call distinct over the option set, but it is unsafe for flags, which take value as the next parameter (-encoding utf8
or -release 8
), which in sbt will be to consecutive values in the list.
I would agree that it is a project misconfiguration in sbt build, but reporting the issue here still, because it is very inconsistent with Scala 2 behavior.