scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Should have an option to suppress `-Wnonunit-statement` globally #12938

Closed tribbloid closed 4 months ago

tribbloid commented 4 months ago

This is one of the few options that cannot be actively suppressed by -Wconf, GPT-4 even suggest a ridiculous category name for it.

image

Can it be added into the list of categories under -Wconf?

som-snytt commented 4 months ago

A country can be a non-cooperative state in the global fight against money laundering.

I wish I had demanded compensation in options.

via https://github.com/scala/scala/pull/10093/files

Compile / scalacOptions += "-Wconf:cat=other-pure-statement&site=.*Macro.*:s",
lrytz commented 4 months ago

Also try -Wconf:any:warning-verbose (and -Wconf:help):

➜ sandbox s -Wnonunit-statement -Wconf:any:warning-verbose
Welcome to Scala 2.13.12 (OpenJDK 64-Bit Server VM, Java 21.0.1).
Type in expressions for evaluation. Or try :help.

scala> def f = 1
def f: Int

scala> def g: Unit = f
                     ^
       warning: unused value of type Int (add `: Unit` to discard silently)
       Applicable -Wconf / @nowarn filters for this warning: msg=<part of the message>, cat=other-pure-statement, site=g
som-snytt commented 4 months ago

I proposed verbose warnings for sbt-tpolecat because a) TIL and b) am I supposed to edit my build.sbt every time I need it? Ad hoc options are irritating (see re-run with -deprecation).

By TIL, I mean, "Oh yeah, right, pandemic brain fog, how does it go again?" Took me a couple of tries to get Scala 3 right.

tribbloid commented 4 months ago

oh sorry I wasn't aware of that, so GPT4 did speak a grain of truth

lrytz commented 4 months ago

Creating plausible sounding answers is what the bot was designed to do

tribbloid commented 4 months ago

all they ever need is a draft paper to interact with and validate ideas, which is already part of Scala reflection API but even Copilot refused to use :-<