Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow shading of single-choice compiler options from the command line regardless of -/-- prefix #3279

Merged

Conversation

Gedochao
Copy link
Contributor

@Gedochao Gedochao commented Nov 14, 2024

Scala CLI allows (even before this PR) to override using directive settings from the command line, including single-choice (non-repeatable) compiler options.

Given a source file unused.scala:

//> using options -Wunused:all -Werror
@main def main() = {
  val unusedValue = "something"
  println("Hello, world!")
}

The unused warning produced by -Wunused:all would get raised to an error due to -Werror.

scala-cli compile unused.scala
# Compiling project (Scala 3.5.1, JVM (17))
# [warn] ./repro.scala:3:7
# [warn] unused local definition
# [warn]   val unusedValue = "something"
# [warn]       ^^^^^^^^^^^
# Error: No warnings can be incurred under -Werror (or -Xfatal-warnings)
# Error compiling project (Scala 3.5.1, JVM (17))
# Compilation failed

However, -Werror can be overridden from the command line with -Werror:false, without editing sources:

scala-cli compile repro.scala -Werror:false                      
# Compiling project (Scala 3.5.1, JVM (17))
# [warn] ./repro.scala:3:7
# [warn] unused local definition
# [warn]   val unusedValue = "something"
# [warn]       ^^^^^^^^^^^
# Compiled project (Scala 3.5.1, JVM (17))

This PR allows to perform overriding like this regardless if the option key is preceded with a single - (-Werror) or double (--Werror).
So this allows for an override like:

scala-cli compile repro.scala --Werror:false                    
# Compiling project (Scala 3.5.1, JVM (17))
# [warn] ./repro.scala:3:7
# [warn] unused local definition
# [warn]   val unusedValue = "something"
# [warn]       ^^^^^^^^^^^
# Compiled project (Scala 3.5.1, JVM (17))

Dependencies:

@Gedochao Gedochao force-pushed the maintenance/scalac-options-tweaks-sequel branch from 8941fa5 to 50a0e72 Compare November 14, 2024 12:03
@Gedochao Gedochao requested a review from tgodzik November 15, 2024 09:10
@Gedochao Gedochao marked this pull request as ready for review November 15, 2024 09:10
@Gedochao Gedochao added the needs-minor-release This change should require a minor version bump. label Nov 15, 2024
@Gedochao Gedochao force-pushed the maintenance/scalac-options-tweaks-sequel branch from 50a0e72 to 69631fc Compare November 21, 2024 17:19
@Gedochao Gedochao requested a review from tgodzik November 21, 2024 17:20
@Gedochao Gedochao merged commit cba8f54 into VirtusLab:main Nov 25, 2024
79 checks passed
@Gedochao Gedochao deleted the maintenance/scalac-options-tweaks-sequel branch November 25, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This change should require a minor version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants