-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Compiler version
3.3.7, 3.8.1-RC1-bin-20251129-7eab684-NIGHTLY
Minimized code
//> using scala 3.3.7
//> using options -Wunused:all
import scala.annotation.unused
val transforms: Seq[(String, Int)] = Nil
transforms.foreach((str, @unused int) => println(str))Output
-- [E018] Syntax Error: --------------------------------------------------------
7 |transforms.foreach((str, @unused int) => println(str))
| ^
| expression expected but @ found
|
| longer explanation available when compiling with `-explain`
Expectation
If I omit @unused, the compiler warns about int being "unused local definition", as expected.
To resolve this, I should be able to add @unused annotation to int, but doing so causes the syntax error above.
Workaround: rename
intto_– but that's inconvenient because I have commented-out code that refers toint.
I'm not sure if this is a bug or feature request, but I think the @unused syntax should work with untupled parameters the same as it does in other contexts.
Also, I was sort of half-expecting the warning to call out "unused explicit parameter" rather than "unused local definition". Doesn't make a difference to me, but might for people who set only one of -Wunused:local and -Wunused:param options.