Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: compiler crash on existentials and pattern matching #5119

Closed
scabug opened this issue Oct 26, 2011 · 4 comments
Closed

regression: compiler crash on existentials and pattern matching #5119

scabug opened this issue Oct 26, 2011 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Oct 26, 2011

import collection.mutable

object Test {
  class IMap0[K[_], V[_]](backing: Map[K[_], V[_]]) {
    def mapSeparate[VL[_], VR[_]](f: V[_] => ({type l[T] = Either[VL[T], VR[T]]})#l[_] ) = {
      backing.view.map { case (k,v) => f(v) match {
	case Left(l) => Left((k, l))
	case Right(r) => Right((k, r))
        }
      }
    }
  }
}

You can probably reduce it more but I didn't have a heart for that.
I will just add initial stacktrace because full is really long:

exception when traversing ((x0$1: (K[_], V[_])) => x0$1 match {
  case (_1: K[_], _2: V[_])(K[_], V[_])((k @ _), (v @ _)) => f.apply(v) match {
    case (a: VL[_$4])Left[VL[_$4],VR[_$4]]((l @ _)) => new Left[(K[_0], VL[_$4]),Nothing](new (K[_0], VL[_$4])(k, l))
    case (b: VR[_$4])Right[VL[_$4],VR[_$4]]((r @ _)) => new Right[Nothing,(K[_0], VR[_$4])](new (K[_0], VR[_$4])(k, r))
  }
})
exception when traversing IMap0.this.backing.view.map[Product1[(K[_ >: _0 with _0], Any)] with Serializable with Either[(K[_0], VL[_$4]),(K[_0], VR[_$4])] forSome { type _0; type _0; type _$4 }, scala.collection.IterableView[Product1[(K[_ >: _0 with _0], Any)] with Serializable with Either[(K[_0], VL[_$4]),(K[_0], VR[_$4])] forSome { type _0; type _0; type _$4 },Iterable[_]]](((x0$1: (K[_], V[_])) => x0$1 match {
  case (_1: K[_], _2: V[_])(K[_], V[_])((k @ _), (v @ _)) => f.apply(v) match {
    case (a: VL[_$4])Left[VL[_$4],VR[_$4]]((l @ _)) => new Left[(K[_0], VL[_$4]),Nothing](new (K[_0], VL[_$4])(k, l))
    case (b: VR[_$4])Right[VL[_$4],VR[_$4]]((r @ _)) => new Right[Nothing,(K[_0], VR[_$4])](new (K[_0], VR[_$4])(k, r))
  }
}))
exception when traversing IMap0.this.backing.view.map[Product1[(K[_ >: _0 with _0], Any)] with Serializable with Either[(K[_0], VL[_$4]),(K[_0], VR[_$4])] forSome { type _0; type _0; type _$4 }, scala.collection.IterableView[Product1[(K[_ >: _0 with _0], Any)] with Serializable with Either[(K[_0], VL[_$4]),(K[_0], VR[_$4])] forSome { type _0; type _0; type _$4 },Iterable[_]]](((x0$1: (K[_], V[_])) => x0$1 match {
  case (_1: K[_], _2: V[_])(K[_], V[_])((k @ _), (v @ _)) => f.apply(v) match {
    case (a: VL[_$4])Left[VL[_$4],VR[_$4]]((l @ _)) => new Left[(K[_0], VL[_$4]),Nothing](new (K[_0], VL[_$4])(k, l))
    case (b: VR[_$4])Right[VL[_$4],VR[_$4]]((r @ _)) => new Right[Nothing,(K[_0], VR[_$4])](new (K[_0], VR[_$4])(k, r))
  }
....
....
blablabla
....
....
error: scala.reflect.internal.Types$TypeError: type mismatch;
 found   : Product1[(K[_ >: _0(in value $anonfun) with (some other)_0(in value $anonfun)], Any)] with Serializable with Either[(K[_0(in value $anonfun)], VL[_$4(in value $anonfun)]),(K[(some other)_0(in value $anonfun)], VR[_$4(in value $anonfun)])] where type _$4(in value $anonfun), type (some other)_0(in value $anonfun), type _0(in value $anonfun)
 required: Product1[(K[_ >: _0(in value $anonfun) with (some other)_0(in value $anonfun)], Any)] with Serializable with Either[(K[_0(in value $anonfun)], VL[(some other)_$4(in value $anonfun)]),(K[(some other)_0(in value $anonfun)], VR[(some other)_$4(in value $anonfun)])] forSome { type _0(in value $anonfun); type (some other)_0(in value $anonfun); type (some other)_$4(in value $anonfun) }
	at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:283)
	at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:207)
	at scala.tools.nsc.typechecker.Infer$Inferencer.typeError(Infer.scala:217)
	at scala.tools.nsc.typechecker.Infer$Inferencer.typeErrorTree(Infer.scala:255)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:980)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4360)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4507)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1813)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4011)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4351)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2169)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$23.apply(Typers.scala:2257)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$23.apply(Typers.scala:2257)
	at scala.collection.immutable.List.loop$1(List.scala:150)
	at scala.collection.immutable.List.mapConserve(List.scala:166)
....

Failing in uncurry. This crashes sbt when compiling it with trunk.

@scabug
Copy link
Author

scabug commented Oct 26, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5119?orig=1
Reporter: @hubertp
Affected Versions: 2.9.2

@scabug
Copy link
Author

scabug commented Oct 26, 2011

@hubertp said (edited on Oct 26, 2011 12:37:57 PM UTC):
Workaround:

import collection.mutable

object Test {
  class IMap0[K[_], V[_]](backing: Map[K[_], V[_]]) {
    def mapSeparate[VL[_], VR[_]](f: V[_] => ({type l[T] = Either[VL[T], VR[T]]})#l[_] ) = {
      backing.view.map { case (k,v) =>
        (f(v) match {
	case Left(l) => Left((k, l))
	case Right(r) => Right((k, r))
        }): Either[(K[_],VL[_]),(K[_],VR[_])]
      }
    }
  }
}

It is still a regression though.

@scabug
Copy link
Author

scabug commented Oct 26, 2011

@paulp said:
Not the same bug, but yes the same commit. Regressed in r25725, the ProductN commit.

That is a classy stack trace.

@scabug
Copy link
Author

scabug commented Dec 20, 2011

@paulp said:
Test case checked in.

@scabug scabug closed this as completed Dec 20, 2011
@scabug scabug added the critical label Apr 7, 2017
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants