http4s 路由模式匹配中无法访问的代码警告
Unreachable Code warning in http4s route pattern matching
我用 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 =>
....
}
路由按预期运行。
有没有办法避免这个警告?
这是堆栈跟踪:
[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.
Scala 2.13 有一个错误,@jenshalm 在 Gitter 上告诉我。参见 scala/bug#11457
以及@rossabaker 提到的修复。参见 http4s/issues/2933
我用 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 =>
....
}
路由按预期运行。
有没有办法避免这个警告?
这是堆栈跟踪:
[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.
Scala 2.13 有一个错误,@jenshalm 在 Gitter 上告诉我。参见 scala/bug#11457
以及@rossabaker 提到的修复。参见 http4s/issues/2933