Skip to content

Typer regression in zio/zio-schema #24696

@WojciechMazur

Description

@WojciechMazur

Based on the OpenCB failure in zio/zio-schema - build logs

Compiler version

Last good release: 3.8.0-RC1-bin-20251103-714f3b6-NIGHTLY
First bad release: 3.8.0-RC1-bin-20251104-b83b3d9-NIGHTLY

Bisect points to one of:
f3aea49
5b03dca
Both are commits from #24231

Not present in 3.8.0-RCs, merged after 3.8.0 cutoff, but before change of build developed version

Minimized code

trait Schema[A]
object Schema:
    final case class Either[A, B](left: Schema[A], right: Schema[B]) extends Schema[scala.util.Either[A, B]]
trait DecodeError

object DynamicValue:
  final case class LeftValue(value: DynamicValue) extends DynamicValue
  final case class RightValue(value: DynamicValue) extends DynamicValue


sealed trait DynamicValue: 
  self =>
    def toTypedValueLazyError[A](using schema: Schema[A]): Either[DecodeError, A] =
      (self, schema) match 
        case (DynamicValue.LeftValue(value), Schema.Either(schema1, _)) =>
          value.toTypedValueLazyError(using schema1).map(Left(_))
        case (DynamicValue.RightValue(value), Schema.Either(_, schema1)) =>
          value.toTypedValueLazyError(using schema1).map(Right(_))
        case _ => ???

Output

Compiling project (Scala 3.8.1-RC1-bin-20251207-68396ca-NIGHTLY, JVM (21))
[error] ./test.scala:16:58
[error] Found:    Left[A, B]
[error] Required: A²
[error] 
[error] where:    A  is a type variable with constraint >: (_$1 : A$1)
[error]           A² is a type in method toTypedValueLazyError which is an alias of Either[A$1, B$1]
[error]           B  is a type variable
[error]           value.toTypedValueLazyError(using schema1).map(Left(_))
[error]                                                          ^^^^^^^
[error] ./test.scala:18:58
[error] Found:    Right[A, B]
[error] Required: A²
[error] 
[error] where:    A  is a type variable
[error]           A² is a type in method toTypedValueLazyError which is an alias of Either[A$2, B$2]
[error]           B  is a type variable with constraint >: (_$2 : B$2)
[error]           value.toTypedValueLazyError(using schema1).map(Right(_))
[error]                                                          ^^^^^^^^

Expectation

Should compile

Metadata

Metadata

Assignees

Labels

itype:bugregressionThis worked in a previous version but doesn't anymorestat:needs triageEvery issue needs to have an "area" and "itype" label

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions