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

-Wconf options are processed incorrectly #18367

Closed
coreywoodfield opened this issue Aug 8, 2023 · 4 comments · Fixed by #18503
Closed

-Wconf options are processed incorrectly #18367

coreywoodfield opened this issue Aug 8, 2023 · 4 comments · Fixed by #18503
Labels
good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree

Comments

@coreywoodfield
Copy link

Compiler version

3.3.0

Minimized code

object Main {
  def main(args: Array[String]): Unit = Deprecated.deprecated
}

object Deprecated {
  @deprecated("", "")
  def deprecated = ()
}

(anything that will produce a warning that can be configured with -Wconf will do)

Output

scala 2.13.10

$ scala-2.13.10/bin/scalac -Wconf:cat=deprecation:e -Wconf:cat=deprecation:s Test.scala

$ scala-2.13.10/bin/scalac -Wconf:cat=deprecation:s -Wconf:cat=deprecation:e Test.scala
Test.scala:3: error: method deprecated in object Deprecated is deprecated:
  def main(args: Array[String]): Unit = Deprecated.deprecated
                                                   ^
1 error

scala 3.3.0

$ scala3-3.3.0/bin/scalac -Wconf:cat=deprecation:e -Wconf:cat=deprecation:s Test.scala
-- Error: Test.scala:3:51 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 |  def main(args: Array[String]): Unit = Deprecated.deprecated
  |                                        ^^^^^^^^^^^^^^^^^^^^^
  |                                        method deprecated in object Deprecated is deprecated since : 
1 error found

$ scala3-3.3.0/bin/scalac -Wconf:cat=deprecation:s -Wconf:cat=deprecation:e Test.scala

Expectation

In scala 2, passing -Wconf:cat=deprecation:silent after -Wconf:cat=deprecation:error would override the error setting, i.e. the last provided configuration wins. In scala 3, the opposite is true: the first provided configuration wins. The documentation for the behavior is the same for both: scalac -Wconf:help includes the following:

User-defined configurations are added to the left. The leftmost rule matching
a warning message defines the action.

I would expect that, having the same documentation, the -Wconf flags would be handled in the same order. The scala 2 behavior is useful for providing a general default (e.g. -Wconf:any:error) and then being able to append more specific options to the scalac options and have those override the general default. A bit more discussion can be found in #18365

@coreywoodfield coreywoodfield added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 8, 2023
@Kordyjan
Copy link
Contributor

Kordyjan commented Aug 9, 2023

The leftmost rule matching a warning message defines the action. suggests that if we provide two matching options, the first should be used and the second ignored. Do I understand it wrong?

@som-snytt
Copy link
Contributor

Per the discussion, in Scala 2 the -Wconf option has a flag to prepend values, so command line -Wconf:X -Wconf:Y reverses to Y then X, so if Y matches, it wins. Various switches may tweak the config, such as -Wopt for optimizer warnings. Explicit -Wconf is processed as a final step IIRC to ensure "user conf" winds up at the head. So that is the meaning of leftmost for Scala 2.

Hopefully a judicious list.reverse suffices in Scala 3.

@Kordyjan Kordyjan added itype:enhancement good first issue Perfect for someone who wants to get started contributing Spree Suitable for a future Spree and removed stat:needs triage Every issue needs to have an "area" and "itype" label itype:bug labels Aug 10, 2023
@SethTisue
Copy link
Member

fyi @lrytz

@johnmatthiggins
Copy link
Contributor

I'd like to work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants