Skip to content

False positive unused pattern var warning #12075

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

Closed
philwalk opened this issue Jul 8, 2020 · 3 comments
Closed

False positive unused pattern var warning #12075

philwalk opened this issue Jul 8, 2020 · 3 comments

Comments

@philwalk
Copy link

philwalk commented Jul 8, 2020

reproduction steps

using Scala 2.13.3

package vastblue.apps

object FalsePositiveWarning extends App {
  val rows = Seq.empty[Map[String,Any]]
  for {
    row:Map[String,Any] <- rows
    item = ColItem(row)
  } yield item

  case class ColItem(row:Map[String,Any])
}

problem

The compiler issue this incorrect warning:

[info] Compiling 1 Scala source to C:\opt\ue\apps\target\scala-2.13\classes ...
[warn] C:\opt\ue\apps\src\main\scala\vastblue\apps\FalsePositiveWarning.scala:6:5: pattern var row in value $anonfun is never used: use a wildcard `_` or suppress this warning with `row@_`
[warn]     row:Map[String,Any] <- rows
[warn]     ^
[warn] one warning found
@SethTisue
Copy link
Member

duplicate of #10287, I think?

@philwalk
Copy link
Author

philwalk commented Jul 8, 2020

If we remove the type from row, there is no warning:

package vastblue.apps

object FalsePositiveWarning extends App {
  val rows = Seq.empty[Map[String,Any]]
  for {
    row /* : Map[String,Any] */ <- rows
    item = ColItem(row)
  } yield item

  case class ColItem(row:Map[String,Any])
}

Perhaps it has the same underlying cause as #10287, although it's not obvious to me ...

@SethTisue
Copy link
Member

adding a type ascription changes the desugaring

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

No branches or pull requests

2 participants