oleg-py/better-monadic-for

Scala 2.11: local val in value $anonfun is never used

Opened this issue · 0 comments

When building tests for catsTests for Scala 2.11.12 with -Ywarn-unused, I get a following lint warning:

[warn] /tmp/better-monadic-for/cats-tests/src/test/scala/com/olegpy/bm4/CatsSyntaxTest.scala:37:13: local val in value $anonfun is never used
[warn]           _ <- "dummy".pure[F]
[warn]             ^

A minimal (?) example for this looks like this:

def f[F[_]: Monad] =
  for {
    _ <- "dummy".pure[F]
    a = 1
  } yield a

Additionally, under the same conditions this code:

import cats.Monad
import cats.implicits._

object Foo {
  def foo[F[_]: Monad]: F[Unit] =
    for {
      _ <- ().pure[F]
      (a, b) = (1, 2)
      _ = println(s"($a, $b)")
    } yield ()
}

also produces warnings:

[warn] /tmp/better-monadic-for/cats-tests/src/test/scala/com/olegpy/bm4/Foo.scala:8:7: local val in value $anonfun is never used
[warn]       (a, b) = (1, 2)
[warn]       ^
[warn] /tmp/better-monadic-for/cats-tests/src/test/scala/com/olegpy/bm4/Foo.scala:9:18: local val in value $anonfun is never used
[warn]       _ = println(s"($a, $b)")
[warn]                  ^

These two seem to be introduced in 5eba85b.