scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Typer regression for users of `scalanlp/breeze`

Open WojciechMazur opened this issue 6 days ago • 0 comments

Based on OpenCB failure in:

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: f3aea49b6f7754ffa79beab007fcdac4a37dc4c5 5b03dca156e523a20ca232d9c03dc8d53dd4588e 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

Important note: Original code used implcit instead of givens, but both variants reproduce the issue, code base used specialization so it might have behaved differently on Scala 2.13

def Test = Seq.empty[DenseMatrix[Double]].reduce(DenseMatrix.horzcat(_, _))

trait Matrix[T]
trait DenseMatrix[T] extends Matrix[T]

object DenseMatrix:
    def horzcat[M, V](matrices: M*)(using OpSet.InPlaceImpl2[DenseMatrix[V], M]): DenseMatrix[V] = ???

object OpSet extends HasOps:
  trait InPlaceImpl2[V1, V2]

trait HasOps 
object HasOps extends DenseMatrixExpandedOps with DensMatrixLowPriority

trait DenseMatrixExpandedOps:
  given OpSet.InPlaceImpl2[DenseMatrix[Double], DenseMatrix[Double]] = ???

trait DensMatrixLowPriority extends LowPriorityDenseMatrix1
trait LowPriorityDenseMatrix1: 
  given [V]: OpSet.InPlaceImpl2[DenseMatrix[V], Matrix[V]] = ???

Output

-- [E172] Type Error: /Users/wmazur/projects/scala/community-build3/test.scala:1:74 
1 |def Test = Seq.empty[DenseMatrix[Double]].reduce(DenseMatrix.horzcat(_, _))
  |                                                                          ^
  |Ambiguous given instances: both given instance given_InPlaceImpl2_DenseMatrix_DenseMatrix in
  |  trait DenseMatrixExpandedOps and given instance given_InPlaceImpl2_DenseMatrix_Matrix in
  |  trait LowPriorityDenseMatrix1 match type OpSet.InPlaceImpl2[DenseMatrix[Double], M] of parameter x$2 of method horzcat in object DenseMatrix
1 error found

Expectation

Should continue to compile

WojciechMazur avatar Dec 07 '25 01:12 WojciechMazur