-Wunused
false positive in for-comprehension (2.13.15 regression)
#21874
Labels
-Wunused
false positive in for-comprehension (2.13.15 regression)
#21874
Compiler version
2.13.15
Minimized code
https://scastie.scala-lang.org/4Kbf4Z8VTHiwFJehlnp1jA
Output
Expectation
Code snippet should compile fine with
"-Ywarn-unused", "-Xfatal-warnings"
.The compiler complains that
usedVariable
is unused, but it definitely is. The code breaks only when for-comprehension is wrapped in partial function (at least from what I've found). BecauseList(1).flatMap { _ =>
works fine, whileList(1).flatMap { case _ =>
does not 🤔Same code works fine with 2.13.14
https://scastie.scala-lang.org/DVK5oQ3LQgGAFI7hzHjMrw
Scala 3 also works fine.
I guess the issue was introduced because of this ticket #18289 (thank you for that BTW, it's very appreciated despite this bug) . Maybe something went wrong during back porting to Scala 2.
The text was updated successfully, but these errors were encountered: