I have this simple Route defined with http4s:
def routes: HttpRoutes[UserTask] =
HttpRoutes.of[UserTask] {
case GET -> Root / IntVar(id) =>
... // returns a specific user
case GET -> Root => // this line gives the warning
Persistence.>.all().foldM( ... // returns all users
case request@POST -> Root =>
....
}
The Route works as expected.
Is there a way to avoid this warning?
Here is the stacktrace:
[info] Compiling 21 Scala sources to /Users/mpa/dev/Github/pme123/zio-examples/out/entity/compile/dest/classes ...
[warn] /Users/mpa/dev/Github/pme123/zio-examples/entity/src/pme123/zio/examples/api/Api.scala:24:34: unreachable code
[warn] Persistence.>.all().foldM(_ => NotFound(), Ok(_))
[warn] ^
[warn] one warning found
[info] Done compiling.
There is a bug with Scala 2.13, as @jenshalm told me on Gitter. See scala/bug#11457
And a fix as mentioned by @rossabaker. See http4s/issues/2933