Closed
Description
Compiler version
3.2-RC1, 3.2-RC2, 3.2-RC3, 3.2-RC4
Minimized code
@main def main(): Unit =
println(summon[Sum[Minus[Succ[Zero]], Minus[Succ[Zero]]] =:= Minus[Succ[Succ[Zero]]]])
sealed trait IntT
sealed trait NatT extends IntT
final case class Zero() extends NatT
final case class Succ[+N <: NatT](n: N) extends NatT
final case class Minus[+N <: Succ[NatT]](n: N) extends IntT
type NatSum[X <: NatT, Y <: NatT] <: NatT = Y match
case Zero => X
case Succ[y] => NatSum[Succ[X], y]
type NatDif[X <: NatT, Y <: NatT] <: IntT = Y match
case Zero => X
case Succ[y] => X match
case Zero => Minus[Y]
case Succ[x] => NatDif[x, y]
type Sum[X <: IntT, Y <: IntT] <: IntT = Y match
case Zero => X
case Minus[y] => X match
case Minus[x] => Minus[NatSum[x, y]]
case _ => NatDif[X, y]
case _ => X match
case Minus[x] => NatDif[Y, x]
case _ => NatSum[X, Y]
Output
Cannot prove that Minus[NatSum[Succ[Succ[Zero]], NatT]] =:= Minus[Succ[Succ[Zero]]].
Note: a match type could not be fully reduced:
trying to reduce NatSum[Succ[Succ[Zero]], NatT]
failed since selector NatT
does not match case Zero => Succ[Succ[Zero]]
and cannot be shown to be disjoint from it either.
Therefore, reduction cannot advance to the remaining case
case Succ[y] => NatSum[Succ[Succ[Succ[Zero]]], y]
Expectation
Code should compile, as in Scala 3.1.3.