Skip to content

Assertion failed: inconsistent: no typevars were added to committable constraint #7060

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

Closed
Master-Killer opened this issue Aug 17, 2019 · 0 comments

Comments

@Master-Killer
Copy link
Contributor

I was trying to recreate the Post Conditions example:
http://dotty.epfl.ch/docs/reference/contextual/implicit-function-types.html#example-postconditions

So I messed around a little and found an assertion error during compilation using 0.17

minimized code

object PostConditions1 {

  import PostConditions.{ensure, res, Box}

  val v = List(1, 2, 4).sum.ensure(Box(10) => res == 10)
  println(v)
}

object PostConditions {

  class Box[T](val t: T)

  def res[T] given (b: Box[T]): T = b.t

  def (e: T) ensure[T](cond: given Box[T] => Boolean): T = {
    if (cond given Box(e)) e
    else throw new AssertionError("condition not fulfilled")
  }
}
Stack trace
java.lang.AssertionError: assertion failed: inconsistent: no typevars were added to committable constraint  constrained types = PolyType(List(T), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), MethodType(List(e), List(TypeParamRef(T)), MethodType(List(cond), List(AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class ImplicitFunction1),List(AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class PostConditions$)),class Box),List(TypeParamRef(T))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Boolean)))), TypeParamRef(T))))
List(PolyType(List(T), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), MethodType(List(e), List(TypeParamRef(T)), MethodType(List(cond), List(AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class ImplicitFunction1),List(AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class PostConditions$)),class Box),List(TypeParamRef(T))), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),class Boolean)))), TypeParamRef(T)))))
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
	at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:484)
	at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:504)
	at dotty.tools.dotc.typer.Applications$Application.methType(Applications.scala:319)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:339)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:668)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:766)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:839)
	at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:868)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2191)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:879)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:914)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:83)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2001)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
	at dotty.tools.dotc.typer.Namer.typedAheadType$$anonfun$1(Namer.scala:1197)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1190)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1197)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1388)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:755)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:878)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:785)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:251)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:391)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1953)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1978)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2054)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1200)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1190)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1200)
	at dotty.tools.dotc.typer.Namer.completeParams$$anonfun$1(Namer.scala:1215)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.Namer.completeParams(Namer.scala:1215)
 	at dotty.tools.dotc.typer.Namer.defDefSig$$anonfun$3(Namer.scala:1424)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
 	at scala.collection.immutable.List.foreach(List.scala:392)
 	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1424)
 	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:759)
 	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:878)
 	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:785)
 	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:251)
 	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
 	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
 	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:391)
 	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1953)
 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1978)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2054)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2124)
 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2170)
 	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:703)
 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:706)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2008)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:979)
 	at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:801)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2010)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2183)
 	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1541)
 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1988)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2054)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2124)
 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2170)
 	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:703)
 	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:706)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2008)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:979)
 	at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:801)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2010)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.makeContextualFunction(Typer.scala:2081)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2052)
 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3(ProtoTypes.scala:326)
 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:289)
 	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:326)
 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:767)
 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:767)
 	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:531)
 	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:576)
 	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:352)
 	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:668)
 	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:766)
 	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:839)
 	at dotty.tools.dotc.typer.Applications.realApply$4$$anonfun$3(Applications.scala:868)
 	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2191)
 	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:879)
 	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:914)
 	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:83)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2001)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1200)
 	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1190)
 	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1200)
 	at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1335)
 	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1347)
 	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1348)
 	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1359)
 	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1367)
 	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:755)
 	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:878)
 	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:785)
 	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:251)
 	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
 	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
 	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:391)
 	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1953)
 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1978)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2054)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2124)
 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2170)
 	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1670)
 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1991)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2054)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2124)
 	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2170)
 	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1794)
 	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2031)
 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2055)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2093)
 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2105)
 	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2183)
 	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:75)
 	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
 	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:41)
 	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:79)
 	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:109)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
 	at scala.collection.immutable.List.foreach(List.scala:392)
 	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:109)
 	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:158)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
 	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
 	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
 	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
 	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
 	at dotty.tools.dotc.Run.runPhases$5(Run.scala:170)
 	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:178)
 	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
 	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
 	at dotty.tools.dotc.Run.compileUnits(Run.scala:185)
 	at dotty.tools.dotc.Run.compileSources(Run.scala:120)
 	at dotty.tools.dotc.Run.compile(Run.scala:104)
 	at dotty.tools.dotc.Driver.doCompile(Driver.scala:34)
 	at dotty.tools.dotc.Driver.process(Driver.scala:172)
 	at dotty.tools.dotc.Main.process(Main.scala)
 	at xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:69)
 	at xsbt.CompilerInterface.run(CompilerInterface.java:41)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
 	at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:237)
 	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
 	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
 	at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
 	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
 	at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:133)
 	at sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:73)
 	at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:116)
 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:307)
 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:307)
 	at sbt.internal.inc.Incremental$.doCompile(Incremental.scala:106)
 	at sbt.internal.inc.Incremental$.$anonfun$compile$4(Incremental.scala:87)
 	at sbt.internal.inc.IncrementalCommon.recompileClasses(IncrementalCommon.scala:116)
 	at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:63)
 	at sbt.internal.inc.Incremental$.$anonfun$compile$3(Incremental.scala:89)
 	at sbt.internal.inc.Incremental$.manageClassfiles(Incremental.scala:134)
 	at sbt.internal.inc.Incremental$.compile(Incremental.scala:80)
 	at sbt.internal.inc.IncrementalCompile$.apply(Compile.scala:67)
 	at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:311)
 	at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:269)
 	at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:159)
 	at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:238)
 	at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:69)
 	at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:1549)
 	at sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:1523)
 	at scala.Function1.$anonfun$compose$1(Function1.scala:44)
 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
 	at sbt.std.Transform$$anon$4.work(System.scala:67)
 	at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
 	at sbt.Execute.work(Execute.scala:278)
 	at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 	at java.base/java.lang.Thread.run(Thread.java:835)
odersky added a commit to dotty-staging/dotty that referenced this issue Aug 19, 2019
odersky added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2019
odersky added a commit that referenced this issue Aug 26, 2019
Fix #7060: Make single-parameter `constrained` more versatile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant