[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=unused-pat-vars, site=FalsePositiveUnused.notOk1.$anonfun.$anonfun.usedVariable
[error] usedVariable = result
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=unused-pat-vars, site=FalsePositiveUnused.notOk2.$anonfun.$anonfun.usedVariable
[error] usedVariable = result
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). Because List(1).flatMap { _ => works fine, while List(1).flatMap { case _ => does not 🤔
I guess the issue was introduced because of this ticket https://github.com/scala/scala3/issues/18289 (thank you for that BTW, it's very appreciated despite this bug) . Maybe something went wrong during back porting to Scala 2.
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 thatusedVariable
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 https://github.com/scala/scala3/issues/18289 (thank you for that BTW, it's very appreciated despite this bug) . Maybe something went wrong during back porting to Scala 2.