Skip to content

false positive unused warning in for comprehensions #13095

Closed
scala/scala
#11012
@xuwei-k

Description

@xuwei-k

Reproduction steps

Scala 2.13.15, 2.13.16 and 2.13.17-bin-ebdaf73

build.sbt

Global / resolvers += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"

scalaVersion := "2.13.17-bin-ebdaf73"

scalacOptions += "-Wunused"

Main.scala

case class A(x: Int, y: Int)

object Main {
  for {
    a <- List.empty[A]
    A(x, y) = a
  } yield x + y
}

Problem

[warn] false-positive-unused-warn/Main.scala:6:7: pattern var x in value $anonfun is never used
[warn]     A(x, y) = a
[warn]       ^
[warn] false-positive-unused-warn/Main.scala:6:10: pattern var y in value $anonfun is never used
[warn]     A(x, y) = a
[warn]          ^
[warn] two warnings found

x and y not unused.

Metadata

Metadata

Assignees

Labels

fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions