Skip to content

Assertion Error in OrderingConstraint #3213

Closed
@allanrenucci

Description

@allanrenucci

The following code snippet crashes the compiler:

import fastparse.all._

class Test {
  "Hello".rep(1)
}
Stacktrace
java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:204)
	at dotty.tools.dotc.core.OrderingConstraint.add(OrderingConstraint.scala:296)
	at dotty.tools.dotc.core.OrderingConstraint.add(OrderingConstraint.scala:283)
	at dotty.tools.dotc.core.ConstraintHandling.addToConstraint(ConstraintHandling.scala:329)
	at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:399)
	at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:404)
	at dotty.tools.dotc.typer.ProtoTypes$.op$1(ProtoTypes.scala:447)
	at dotty.tools.dotc.typer.ProtoTypes$.normalize(ProtoTypes.scala:444)
	at dotty.tools.dotc.typer.Applications$ApplicableToTrees.argType(Applications.scala:515)
	at dotty.tools.dotc.typer.Applications$ApplicableToTreesDirectly.argOK(Applications.scala:526)
	at dotty.tools.dotc.typer.Applications$ApplicableToTreesDirectly.argOK(Applications.scala:526)
	at dotty.tools.dotc.typer.Applications$TestApplication.addArg(Applications.scala:499)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:410)
	at dotty.tools.dotc.typer.Applications$Application.tryDefault$1(Applications.scala:430)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:461)
	at dotty.tools.dotc.typer.Applications$Application.tryDefault$1(Applications.scala:431)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:461)
	at dotty.tools.dotc.typer.Applications$Application.tryDefault$1(Applications.scala:431)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:461)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:459)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:231)
	at dotty.tools.dotc.typer.Applications$TestApplication.(Applications.scala:507)
	at dotty.tools.dotc.typer.Applications$ApplicableToTrees.(Applications.scala:514)
	at dotty.tools.dotc.typer.Applications$ApplicableToTreesDirectly.(Applications.scala:525)
	at dotty.tools.dotc.typer.Applications.isDirectlyApplicable$$anonfun$1(Applications.scala:1012)
	at scala.compat.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:12)
	at dotty.tools.dotc.core.TyperState.test(TyperState.scala:104)
	at dotty.tools.dotc.typer.Applications.isDirectlyApplicable(Applications.scala:1012)
	at dotty.tools.dotc.typer.Applications.$anonfun$15(Applications.scala:1342)
	at scala.collection.TraversableLike.$anonfun$filterImpl$1(TraversableLike.scala:248)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at scala.collection.TraversableLike.filterImpl(TraversableLike.scala:247)
	at scala.collection.TraversableLike.filterImpl$(TraversableLike.scala:245)
	at scala.collection.AbstractTraversable.filterImpl(Traversable.scala:104)
	at scala.collection.TraversableLike.filter(TraversableLike.scala:259)
	at scala.collection.TraversableLike.filter$(TraversableLike.scala:259)
	at scala.collection.AbstractTraversable.filter(Traversable.scala:104)
	at dotty.tools.dotc.typer.Applications.narrowByTrees$1(Applications.scala:1342)
	at dotty.tools.dotc.typer.Applications.op$1(Applications.scala:1361)
	at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:1279)
	at dotty.tools.dotc.typer.Applications.op$2(Applications.scala:1265)
	at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:1220)
	at dotty.tools.dotc.typer.Typer.adaptOverloaded$1(Typer.scala:1908)
	at dotty.tools.dotc.typer.Typer.adaptInterpolated(Typer.scala:2257)
	at dotty.tools.dotc.typer.Typer.op$4(Typer.scala:1851)
	at dotty.tools.dotc.typer.Typer.op$1(Typer.scala:1847)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:1846)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1690)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1688)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1747)
	at dotty.tools.dotc.typer.Applications.op$22(Applications.scala:676)
	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:1628)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1675)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1690)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1688)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1723)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1735)
	at dotty.tools.dotc.typer.Typer.op$15(Typer.scala:1405)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1335)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1619)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1674)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1690)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1688)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1712)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1735)
	at dotty.tools.dotc.typer.Typer.op$12(Typer.scala:1518)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1505)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1658)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1675)
	at dotty.tools.dotc.typer.Typer.op$8(Typer.scala:1690)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1688)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1747)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:64)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:32)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:68)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:93)
	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:93)
	at dotty.tools.dotc.Run.op$1(Run.scala:124)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$2$$anonfun$1(Run.scala:122)
	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.compileUnits$$anonfun$1(Run.scala:135)
	at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:86)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:137)
	at dotty.tools.dotc.Run.compileSources(Run.scala:95)
	at dotty.tools.dotc.Run.compile(Run.scala:79)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:63)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:53)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:37)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:53)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply$mcV$sp(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
	at sbt.compiler.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:74)
	at sbt.compiler.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:49)
	at sbt.compiler.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:64)
	at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
	at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:66)
	at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:64)
	at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:32)
	at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:72)
	at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:71)
	at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:99)
	at sbt.inc.Incremental$.compile(Incremental.scala:71)
	at sbt.inc.IncrementalCompile$.apply(Compile.scala:54)
	at sbt.compiler.IC$.compileInternal(IncrementalCompiler.scala:160)
	at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138)
	at sbt.Compiler$.compile(Compiler.scala:155)
	at sbt.Compiler$.compile(Compiler.scala:141)
	at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:886)
	at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:877)
	at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:875)
	at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
	at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
	at sbt.std.Transform$$anon$4.work(System.scala:63)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
	at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
	at sbt.Execute.work(Execute.scala:237)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
	at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
	at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
 

There is a dependency on "com.lihaoyi" %% "fastparse" % "0.4.4". I'll try to minimise further and remove the dependency

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions