Closed
Description
Compiler version
3.4.0-RC1-bin-20230729-a73316a-NIGHTLY - failing, current nightly
3.3.2-RC1-bin-20230715-4851278-NIGHTLY - first bad release (first bad commit: 18f90d9)
3.3.2-RC1-bin-20230714-04eae14-NIGHTLY - last good release
Minimized code
trait Zippable[-A, -B] {
type Out
def zip(left: A, right: B): Out
}
object Zippable extends ZippableLowPrio:
given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) =
(left, right) => left :* right
trait ZippableLowPrio:
given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) =
(left, right) => (left, right)
def zip[A, B](a: A, b: B)(using z: Zippable[A, B]) = z.zip(a, b)
object Test:
val x1: (Int, Int) = zip(1, 2)
val x2: (Int, Int, Int) = zip((1, 2), 3)
val x3: (Int, Int, Int, Int) = zip((1, 2, 3), 4)
Output
-- [E008] Not Found Error: Zippable.scala:8:26
8 | (left, right) => left :* right
| ^^^^^^^
| value :* is not a member of A
-- [E007] Type Mismatch Error: Zippable.scala:12:21
12 | (left, right) => (left, right)
| ^^^^^^^^^^^^^
| Found: (A, B)
| Required: Zippable.this.Out
|
| longer explanation available when compiling with `-explain`
With -explain
enabled:
[error] Zippable.scala:8:22
[error] value :* is not a member of A
[error] (left, right) => left :* right
[error] ^^^^^^^
[error] Zippable.scala:12:22
[error] Found: (A, B)
[error] Required: Zippable.this.Out
[error]
[error] Explanation
[error] ===========
[error]
[error] Tree: Tuple2.apply[A, B](left, right)
[error] I tried to show that
[error] (A, B)
[error] conforms to
[error] Zippable.this.Out
[error] but the comparison trace ended with `false`:
[error]
[error] ==> (A, B) <: Zippable.this.Out
[error] <== (A, B) <: Zippable.this.Out = false
[error]
[error] The tests were made under the empty constraint
[error] (left, right) => (left, right)
[error] ^^^^^^^^^^^^^
Expectation
The code should compile successfully