Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala does not warn about unused computation or value

I have this little scala example:

object Test {
  def add(x: Int, y: Int) = {
    val z = x - y
    x match {
      case 0 => 0 - y
      case 1 => 1 - y
      case _ => x - y
    }
    x + y
  }

  def main(args: Array[String]) {
    println(add(5, 6))
  }
}

I feel that scala should warn about 'z' and the 'x match ...' being unused. I did not notice any compiler options to turn on more warnings. I'm using scala 2.10.1.

Thoughts? Thanks!

like image 957
Fysx Avatar asked Jul 17 '13 05:07

Fysx


1 Answers

As you can see here, "unused" warnings will be introduced in the next version of scala, 2.11.

Warn about unused private / local terms and types, and unused imports, under -Xlint

You can try them using the last milestone.

like image 100
Giovanni Caporaletti Avatar answered Oct 13 '22 21:10

Giovanni Caporaletti