-
Notifications
You must be signed in to change notification settings - Fork 185
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
RemoveUnused: detect unused function parameters in Scala 3 #1937
Labels
Comments
bjaglin
changed the title
Despite the presence of
RemoveUnused: detect unused function parameters in Scala 3
Feb 21, 2024
-Wunused:params
and the explicit mention of it in https://github.com/lampepfl/dotty/pull/16157, I did not manage to get diagnostics (nor warnings), so I am leaving this out for now
FTR, not fixed as of
(tested via #1951) |
Does it not produce warnings or are those warnings not in semanticdb? |
@tgodzik no warning is emitted by the compiler, I guess it's just a missing feature // UnusedParams.scala
import java.util.List
object UnusedParams {
val f: String => Unit = unused => println("f")
val ff = (unused: String) => println("f")
val fs = (used: String, unused: Long) => println(used)
def g(x: String => Unit): Unit = ???
g{implicit string => println("g")}
} ➜ /tmp scala-cli compile --scala 2.13.14 -Wunused UnusedParams.scala
Compiling project (Scala 2.13.14, JVM (21))
[warn] ./UnusedParams.scala:1:1
[warn] Unused import
[warn] import java.util.List
[warn] ^^^^^^^^^^^^^^^^^^^^^
[warn] ./UnusedParams.scala:4:27
[warn] parameter unused in anonymous function is never used
[warn] val f: String => Unit = unused => println("f")
[warn] ^^^^^^
[warn] ./UnusedParams.scala:5:13
[warn] parameter unused in anonymous function is never used
[warn] val ff = (unused: String) => println("f")
[warn] ^^^^^^^^^^^^^^
[warn] ./UnusedParams.scala:6:27
[warn] parameter unused in anonymous function is never used
[warn] val fs = (used: String, unused: Long) => println(used)
[warn] ^^^^^^^^^^^^
[warn] ./UnusedParams.scala:8:14
[warn] parameter string in anonymous function is never used
[warn] g{implicit string => println("g")}
[warn] ^^^^^^
Compiled project (Scala 2.13.14, JVM (21)) ➜ /tmp scala-cli compile --scala 3.4.2 -Wunused:all UnusedParams.scala
Compiling project (Scala 3.4.2, JVM (21))
[warn] ./UnusedParams.scala:1:18
[warn] unused import
[warn] import java.util.List
[warn] ^^^^
Compiled project (Scala 3.4.2, JVM (21)) |
Actually, it looks like an issue for that was recently filed: scala/scala3#20951 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Despite the presence of
-Wunused:params
and the explicit mention of it in scala/scala3#16157, I did not manage to get diagnostics (nor warnings) for unused parameters with scala 3.4.0-RC2, so the feature is currently documented/tested as Scala2-only.We probably need to report this upstream.
Originally posted by @bjaglin in #1728 (comment)
The text was updated successfully, but these errors were encountered: