Skip to content

Compiler crash: missing bindings #7438

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
flomebul opened this issue Oct 20, 2019 · 1 comment
Closed

Compiler crash: missing bindings #7438

flomebul opened this issue Oct 20, 2019 · 1 comment

Comments

@flomebul
Copy link
Contributor

I make a bug in my program that generate a compiler crash.

I try to minimize the code, but I'm not sure it is minimal...

import scala.annotation.infix
type Tr[+A] = () => Some[A]
@infix inline def (tr: Tr[A]) map[A, B](f: A => B): Tr[B] = ???

class Graph { class Node }

object grobj extends Graph

def (g: Graph) nodesQ: None.type => Some[g.Node] = ???

def run[A](query: None.type => Some[A]): Some[A] = ???

val notABug = run(grobj nodesQ) map (x => x)
val isBuggy = run(grobj nodesQ map (x => x))
Stack trace
exception occurred while typechecking ABug.scala
exception occurred while compiling ABug.scala
java.lang.AssertionError: assertion failed: missing bindings: (f: A => B): queries.Tr[B] in queries.map[Nothing, Nothing](
  {
    def $anonfun(x: <error Wrong number of parameters, expected: 0>): 
      Some[Nothing]
     = x
    closure($anonfun)
  }
) while compiling ABug.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: missing bindings: (f: A => B): queries.Tr[B] in queries.map[Nothing, Nothing](
  {
    def $anonfun(x: <error Wrong number of parameters, expected: 0>): 
      Some[Nothing]
     = x
    closure($anonfun)
  }
)
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.typer.Inliner.computeParamBindings(Inliner.scala:329)
	at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:450)
	at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:115)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$6(Typer.scala:2742)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:2840)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3046)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2452)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2456)
	at dotty.tools.dotc.typer.Applications$TypedApply.addArg(Applications.scala:695)
	at dotty.tools.dotc.typer.Applications$TypedApply.addArg(Applications.scala:694)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:532)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:601)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:353)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:692)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:794)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:867)
	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:920)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2249)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:931)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:966)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:83)
	at dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:1960)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2098)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2117)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3(ProtoTypes.scala:326)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:290)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:326)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:795)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:795)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:532)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:601)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:353)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:692)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:794)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:867)
	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:920)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2249)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:931)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:966)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:83)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2061)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2117)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2165)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1211)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1201)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1211)
	at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1346)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1357)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1358)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1369)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1377)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:765)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:886)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:796)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:257)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:182)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:184)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:397)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2013)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2038)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2116)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2165)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2184)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2228)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1727)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2051)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2116)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2165)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2184)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2228)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1852)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2092)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2117)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2165)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2241)
	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:305)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:109)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:159)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:169)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:177)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:184)
	at dotty.tools.dotc.Run.compileSources(Run.scala:121)
	at dotty.tools.dotc.Run.compile(Run.scala:104)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:178)
	at dotty.tools.dotc.Driver.process(Driver.scala:147)
	at dotty.tools.dotc.Driver.process(Driver.scala:159)
	at dotty.tools.dotc.Driver.main(Driver.scala:186)
	at dotty.tools.dotc.Main.main(Main.scala)
@flomebul
Copy link
Contributor Author

I eventually find some simplification in the source code

type Tr[+A]
inline def (tr: Tr[A]) map[A, B](f: A => B): Tr[B] = ???

def (d: Double) func: None.type => Some[Double] = ???

def run[A](query: None.type => Some[A]): Some[A] = ???

val noBug = run(3.14 func) map (x => x)
val buggy = run(3.14 func map (x => x))

nicolasstucki added a commit that referenced this issue Oct 30, 2019
Fix #7438: Turn failing assertion into error in inliner
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