Open q-ata opened 11 months ago
A WIP repro: scala-cli test.scala
//> using scala 3.nightly
//> using option -Ysafe-init-global
//> using dep "org.typelevel::cats-parse:1.0.0"
import cats.parse.Parser
object Test:
val alpha: Parser[Char] =
Parser.charIn('A' to 'Z') | Parser.charIn('a' to 'z')
@main def run = println("hello")
Need to do further minimization.
The specific code inside cats-parse that causes the issue is the function Parser::Impl::oneOfInternal
in Parser.scala
. This function in turn calls the List::traverse
function from cats-core which causes the loop.
//> using scala 3.6.1
//> using option -Ysafe-init-global
//> using dep "org.typelevel::cats-core::2.10.0"
import cats.implicits._
object Test:
val alpha: Int =
List(1, 2, 3).traverse[Option, Int] {
case _ => None
} match {
case _ =>
5
}
Need to investigate cats-core for a zero dependency test case.
Compiler version
Scala compiler version 3.4.0-RC1-bin-SNAPSHOT-git-55c2002 (commit 55c20020c24d9edcc8577e9b62c5935e358efbfa)
Issue
When trying to compile the
http4s
community project with the-Ysafe-init-global
flag, the compilation hangs and appears to encounter an infinite loop.The issue appears to stem from the
cats
project, which is a dependency and occurs when the checker tries to analyze theEval
object inEval.scala
.I tried changing the definition of
flatMap
inEval.scala:92
to some dummy value as follows:Doing so and recompiling
http4s
produces a stack overflow error instead of an infinite loop with the following stack trace: