Skip to content

Report if unused var was mutated but not read #23704

@ViveLeQuebec

Description

@ViveLeQuebec

Compiler version

3.7.2

Minimized code

trait Test {
  def incr(): Unit
}

object Test {
  val test = new Test {
    var position: Int = 0

    def incr(): Unit = { position += 1 }
  }
}

Output

[warn] -- [E198] Unused Symbol Warning: Test.scala:9:8 
[warn] 9 |    var position: Int = 0
[warn]   |        ^^^^^^^^^^
[warn]   |        unused private member

Expectation

Compiles without warnings.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions