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

Unused value warning in pattern match expression #8040

Closed
scabug opened this issue Dec 6, 2013 · 4 comments
Closed

Unused value warning in pattern match expression #8040

scabug opened this issue Dec 6, 2013 · 4 comments

Comments

@scabug
Copy link

scabug commented Dec 6, 2013

There is already a warning for unused values, fields, imports etc. what no warning for unused variables bound in a pattern match:

scala> def f(x: Any): Unit = x match { case y => println(x) }
f: (x: Any)Unit

y is never used, thus the compiler should warn about it.

@scabug
Copy link
Author

scabug commented Dec 6, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8040?orig=1
Reporter: @sschaef
Affected Versions: 2.11.0
See #7707, #9158, #9518, #7712

@scabug
Copy link
Author

scabug commented Dec 7, 2013

@paulp said:
I initially did that, then backed off in terror from the hundreds if not thousands of warnings the compiler emitted. The prevailing style inside the compiler involves a lot of pattern matches like this:

      case ValDef(mods, name, tpt, rhs) =>
        ctx // we use the symbol to add fields
      case DefDef(mods, name, tparams, vparamss, tpt, rhs) =>
        // let's do nothing!

That's ten unused warnings, now multiply by one billion. Maybe this problem is unique to the compiler.

@scabug
Copy link
Author

scabug commented Aug 19, 2016

@som-snytt said (edited on Aug 19, 2016 6:42:06 PM UTC):
There are a few specific examples for improving unused warning.

Another request: unused parameters, especially implicits, and also when shadowed by locals.

Don't warn if param is mandated by superclass API, or if param is deprecated.

@scabug
Copy link
Author

scabug commented Sep 15, 2016

@som-snytt said:
scala/scala#5402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants