You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for loops in Scala 3 (and 2.x) support guards, however the following does not compile:
defgetNums():UIO[List[Int]] =ZIO.succeed(List(1, 2, 3))
defprintNum(n: Int):UIO[Unit] =ZIO.succeed(println(n))
defer {
for {
n <- getNums().run
if n %2==0
} printNum(n).run // Error: While expanding a macro, a reference to parameter n
} // was used outside the scope where it was defined
It seems it has something to do with how guards are desugared, the following also doesn't compile:
defer {
getNums().run.withFilter(n => n %2==0).foreach(n => printNum(n).run)
}
whereas replacing withFilter with filter successfully compiles.
The text was updated successfully, but these errors were encountered:
for
loops in Scala 3 (and 2.x) support guards, however the following does not compile:It seems it has something to do with how guards are desugared, the following also doesn't compile:
whereas replacing
withFilter
withfilter
successfully compiles.The text was updated successfully, but these errors were encountered: