Skip to content

Exception in thread "main" java.lang.AssertionError: cannot merge Constraint(...) #4272

Closed
@michelou

Description

@michelou

Scala source code:

object Main {

  final case class C(m: Map[String, Boolean])

  def main(args: Array[String]): Unit = {
    // println(C(Map("a" -> true)))  // C(Map(a -> true))
    println(C(Map('a' -> true)))  // Scala: one error found, Dotty: runtime exception
  }

}

Scala compiler output (MS Windows 7 SP1, Java SDK 1.8.0_161):

> scalac -version
Scala compiler version 2.12.5 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.

> scalac -d c:\temp\classes src\main\scala\Main.scala
src\main\scala\Main.scala:7: error: type mismatch;
 found   : (Char, Boolean)
 required: (String, Boolean)
    println(C(Map('a' -> true)))  // Scala: one error found, Dotty: runtime exception
                      ^
one error found

Dotty compiler output (MS Windows 7 SP1, Java SDK 1.8.0_161):

> dotc -version
Dotty compiler version 0.7.0-RC1 -- Copyright 2002-2018, LAMP/EPFL

> dotc -d c:\temp\classes src\main\scala\Main.scala
exception occurred while typechecking src\main\scala\Main.scala
exception occurred while compiling src\main\scala\Main.scala
Exception in thread "main" java.lang.AssertionError: cannot merge Constraint(
 uninstVars = A;
 constrained types = [A, B](elems: (A, B)*): Map[A, B]
 bounds =
     A >: Char
     B := Boolean
 ordering =
) with Constraint(
 uninstVars = A, Boolean;
 constrained types = [A, B](elems: (A, B)*): Map[A, B]
 bounds =
     A >: String <: String
     B <: Boolean
 ordering =
)
        at dotty.tools.dotc.core.OrderingConstraint.mergeError$1(OrderingConstraint.scala:538)
        at dotty.tools.dotc.core.OrderingConstraint.mergeEntries$1(OrderingConstraint.scala:535)
        at dotty.tools.dotc.core.OrderingConstraint.$amp$$anonfun$1(OrderingConstraint.scala:542)
        at dotty.tools.dotc.core.OrderingConstraint.mergeArrays$1$$anonfun$1(OrderingConstraint.scala:509)
        at scala.compat.java8.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.java:12)
        at scala.collection.immutable.Range.foreach(Range.scala:156)
        at dotty.tools.dotc.core.OrderingConstraint.mergeArrays$2(OrderingConstraint.scala:509)
        at dotty.tools.dotc.core.OrderingConstraint.merge$2$$anonfun$1(OrderingConstraint.scala:514)
        at scala.compat.java8.JProcedure2.apply(JProcedure2.java:18)
        at scala.compat.java8.JProcedure2.apply(JProcedure2.java:10)
        at dotty.tools.dotc.util.SimpleIdentityMap$Map1.foreachBinding(SimpleMap.scala:56)
        at dotty.tools.dotc.core.OrderingConstraint.merge$1(OrderingConstraint.scala:514)
        at dotty.tools.dotc.core.OrderingConstraint.$amp(OrderingConstraint.scala:542)
        at dotty.tools.dotc.core.TyperState.commit(TyperState.scala:158)
        at dotty.tools.dotc.typer.Applications.fail$1(Applications.scala:732)
        at dotty.tools.dotc.typer.Applications.realApply$6$$anonfun$5$$anonfun$2(Applications.scala:738)
        at scala.Option.getOrElse(Option.scala:121)
        at dotty.tools.dotc.typer.Applications.realApply$7$$anonfun$6(Applications.scala:739)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1882)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:674)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:774)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1740)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1791)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$1(ProtoTypes.scala:244)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:222)
        at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:244)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:645)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:645)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:414)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:454)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:235)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:546)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:644)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:704)
        at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:729)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1880)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:674)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:774)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1740)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1791)
        at dotty.tools.dotc.typer.Typer.op1$2(Typer.scala:1807)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1803)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1872)
        at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:665)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1747)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1791)
        at dotty.tools.dotc.typer.Typer.op1$2(Typer.scala:1807)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1803)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1872)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1387)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1728)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1790)
        at dotty.tools.dotc.typer.Typer.op1$2(Typer.scala:1807)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1803)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1831)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1860)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1432)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1731)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1790)
        at dotty.tools.dotc.typer.Typer.op1$2(Typer.scala:1807)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1803)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1831)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1860)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1600)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1771)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1791)
        at dotty.tools.dotc.typer.Typer.op1$2(Typer.scala:1807)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1803)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1872)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:66)
        at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
        at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:70)
        at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:95)
        at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
        at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:389)
        at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:95)
        at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:168)
        at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
        at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
        at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
        at dotty.tools.dotc.Run.runPhases$5(Run.scala:183)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:191)
        at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:198)
        at dotty.tools.dotc.Run.compileSources(Run.scala:136)
        at dotty.tools.dotc.Run.compile(Run.scala:120)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:29)
        at dotty.tools.dotc.Driver.process(Driver.scala:127)
        at dotty.tools.dotc.Driver.process(Driver.scala:96)
        at dotty.tools.dotc.Driver.process(Driver.scala:108)
        at dotty.tools.dotc.Driver.main(Driver.scala:135)
        at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions