Closed
Description
Compiler version
3.2.0. Also tried 3.3.0-RC2 and found the same bug.
Cats Effect version
3.4.8
Minimized code
import cats.effect.IO
val someIOOp: IO[(Int, String)] = IO.pure((1,"sample"))
for {
(num, str) <- someIOOp
} yield ()
Output
[error] 44 | (num, str) <- someIOOp
[error] | ^^^^^^^^
[error] | value withFilter is not a member of cats.effect.IO[(Int, String)]
Expectation
Expected that decomposition would succeed inside the for comprehension and that num
and str
would be parsed to Int
and String
respectively. The compiler parses a normal flatMap call correctly. So the following correctly returns the number:
someIOOp.flatMap { (num, str) =>
IO(num)
}
It's just decomposition inside the for comprehension that fails for the IO. This bug does not affect Option, but it does affect Either, since Either lacks the .withFilter
method.