Skip to content

Packages mixed type inference crashes compiler #11430

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
romanowski opened this issue Feb 16, 2021 · 0 comments · Fixed by #11431
Closed

Packages mixed type inference crashes compiler #11430

romanowski opened this issue Feb 16, 2021 · 0 comments · Fixed by #11431

Comments

@romanowski
Copy link
Contributor

There is no import in scope and I found it out when I anciently copied piece of code that was missing value org.

Compiler version

3.0.0-M4-bin-SNAPSHOT-git-53a2dc5 (latest master) as well as 3.0.0-M3

Minimized code

// crashes the compiler
def a(o: String) = Seq(o, org)

// Reports problem property
def a2(o: String) = Seq[String](o, org) // package org is not a value
def a3(o: String): Seq[String] = Seq(o, org) // Found:    org.type Required: String
def a4(o: String): Seq[String] = Seq(o, org) // Found:    org.type Required: String

Output (click arrow to expand)

Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.core.TypeOps$.dominators$1(TypeOps.scala:210)
	at dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:330)
	at dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:338)
	at dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:316)
	at dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:338)
	at dotty.tools.dotc.core.Types$OrType.join(Types.scala:3119)
	at dotty.tools.dotc.core.Types$Type.widenUnionWithoutNull(Types.scala:1256)
	at dotty.tools.dotc.core.Types$Type.widenUnion(Types.scala:1251)
	at dotty.tools.dotc.core.ConstraintHandling.widenOr$1(ConstraintHandling.scala:402)
	at dotty.tools.dotc.core.ConstraintHandling.widenInferred(ConstraintHandling.scala:415)
	at dotty.tools.dotc.core.ConstraintHandling.widenInferred$(ConstraintHandling.scala:26)
	at dotty.tools.dotc.core.TypeComparer.widenInferred(TypeComparer.scala:30)
	at dotty.tools.dotc.core.ConstraintHandling.instanceType(ConstraintHandling.scala:432)
	at dotty.tools.dotc.core.ConstraintHandling.instanceType$(ConstraintHandling.scala:26)
	at dotty.tools.dotc.core.TypeComparer.instanceType(TypeComparer.scala:30)
	at dotty.tools.dotc.core.TypeComparer$.instanceType(TypeComparer.scala:2673)
	at dotty.tools.dotc.core.Types$TypeVar.instantiate(Types.scala:4394)
	at dotty.tools.dotc.typer.Inferencing.doInstantiate$1(Inferencing.scala:617)
	at dotty.tools.dotc.typer.Inferencing.interpolateTypeVars(Inferencing.scala:620)
	at dotty.tools.dotc.typer.Inferencing.interpolateTypeVars$(Inferencing.scala:488)
	at dotty.tools.dotc.typer.Typer.interpolateTypeVars(Typer.scala:102)
	at dotty.tools.dotc.typer.Typer.simplify(Typer.scala:2671)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2657)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2720)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2724)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1305)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1292)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1305)
	at dotty.tools.dotc.typer.Namer.rhsType$1$$anonfun$1(Namer.scala:1447)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:223)
	at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1447)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1458)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1459)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1470)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1479)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1562)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:703)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:826)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:727)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2535)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2560)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2654)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2720)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2724)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2746)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2796)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2226)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2581)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2585)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2654)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2720)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2724)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2746)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2796)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2378)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2626)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2655)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2720)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2724)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2840)
	at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
	at dotty.tools.repl.REPLFrontEnd.runOn(ReplFrontEnd.scala:24)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.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:215)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:223)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:230)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:172)
	at dotty.tools.repl.ReplCompiler.runCompilationUnit(ReplCompiler.scala:151)
	at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:161)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:234)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:197)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:133)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:152)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:133)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 16, 2021
Move the check to Typer so that we get better error messages, and don't fail
subsequent assertions.

Fixes scala#11430
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 16, 2021
Move the check to Typer so that we get better error messages, and don't fail
subsequent assertions.

Fixes scala#11430
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants