This code works for me on 3.5.7 but fails on 3.6.0 (OpenJDK 21 on M1 Mac OS):
import cats.effect.*
import cats.syntax.all.*
object Main extends App {
val syncStepSize = 1000000
val io = for {
ref <- Ref.of[IO, Int](0)
_ <- Vector.fill(100000)(1).traverse_[IO, Unit](n => ref.update(_ + n))
result <- ref.get
} yield result
println(io.syncStep(syncStepSize).unsafeRunSync())
}
Exception in thread "main" java.lang.StackOverflowError
at cats.effect.IO$FlatMap.ioe(IO.scala:2235)
at cats.effect.SyncStep$.interpret(IO.scala:2355)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
at cats.effect.SyncStep$.interpret(IO.scala:2356)
...
I'm not sure if it's a bug or an expected behaviour. It was sure unexpected for me 😄
I tried to debug it a little bit but got lost in syncStep and SyncIO implementations.
This code works for me on 3.5.7 but fails on 3.6.0 (OpenJDK 21 on M1 Mac OS):
I'm not sure if it's a bug or an expected behaviour. It was sure unexpected for me 😄
I tried to debug it a little bit but got lost in
syncStepandSyncIOimplementations.