Skip to content

Typer regressions in getkyo/kyo #24097

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failures in getkyo/kyo - build logs

2 issues found in the same codebase related to the same change

Compiler version

Last good release: 3.8.0-RC1-bin-20250915-afbb66b-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250916-eb1bb73-NIGHTLY

For both bisect points to b1067d9 / #23923

Issue 1

Minimized code

trait <[+A, -S]
object `<`:
  extension [A, S](v: A < S) def map[B, S2](f: A => B < S2): B < (S & S2) = ???

def lift[A, S](v: A): A < S = ???

abstract class ArrowEffect[-Input[_], +Output[_]]
object ArrowEffect:
  inline def handleCatching[I[_], O[_], E <: ArrowEffect[I, O], A, B, S, S2, S3](
      v: A < (E & S)
  ): B < (S & S2 & S3) = ???

trait Result[+E, +A]
object Result:
  def succeed[E, A](value: A): Result[E, A] = ???

abstract class Error[+E]

type Const[A] = [B] =>> A
sealed trait Abort[-E] extends ArrowEffect[Const[Error[E]], Const[Unit]]
object Abort:
  inline def runWith[E, A, S, ER, B, S2](v: A < (Abort[E | ER] & S)) =
    ArrowEffect.handleCatching[
      Const[Error[E]],
      Const[Unit],
      Abort[E],
      Result[E, A],
      B,
      Abort[ER] & S,
      Abort[ER] & S,
      S2
    ](
      v.map: 
        value => lift:
          Result.succeed[E, A](value)
    )

Output

Compiling project (Scala 3.8.0-RC1-bin-20250928-b67fcf2-NIGHTLY, JVM (21))
[error] ./test.scala:33:7
[error] Found:    Result[E, A] < (Abort[E | ER] & S)
[error] Required: Result[E, A] < (Abort[E] & (Abort[ER] & S))

Issue 2

Minimized code

trait <[+A, -S]

trait TypeMap[+A]:
  def union[B](that: TypeMap[B]): TypeMap[A & B] = ???

trait Tag[E]
trait ContextEffect[+A]
object ContextEffect:
  def handle[A, E <: ContextEffect[A], B, S](effectTag: Tag[E], ifDefined: A => A)(
      v: B < (E & S)
  ): B < S = ???

sealed trait Env[+R] extends ContextEffect[TypeMap[R]]
object Env:
  def runAll[R >: Nothing, A, S, VR](
      env: TypeMap[R],
      tag: Tag[Env[R]]
  )(
      v: A < (Env[R & VR] & S)
  ) =
    ContextEffect.handle(
      tag,
      _.union(env)
    )(v): A < (Env[VR] & S)
    ???

Output

Compiling project (Scala 3.8.0-RC1-bin-20250928-b67fcf2-NIGHTLY, JVM (21))
[error] ./test2.scala:24:7
[error] Found:    (v : A < (Env[R & VR] & S))
[error] Required: A < (Env[R] & (Env[VR] & S))
[error] 
[error] where:    R is a type in method runAll
[error]     )(v): A < (Env[VR] & S)
[error]       ^
Error compiling project (Scala 3.8.0-RC1-bin-20250928-b6

Expectation

Both should compile

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions