Skip to content

Missing context bound implicit crashes compiler under -source:3.4-migration #19506

Closed
@WojciechMazur

Description

@WojciechMazur

New regression found in Open CB for com-lihaoyi/upickle
It was not found in the maintained CommunityBuild, because Open CB might automatically add -source:3.x-migration flags.

The issue exists only when we combine -source:3.4-migration, method with context bound and at least 1 default method argument.

Compiler version

Last good release: 3.4.0-RC1-bin-20240109-91db06a-NIGHTLY
First bad release: 3.4.0-RC1-bin-20240112-c50f2ff-NIGHTLY
Bisect points to 13a71ef

Minimized code

//> using options "-source:3.4-migration",

trait Reader[T]
def read[T: Reader](s: String, trace: Boolean = false): T = ???

@main def Test = read[Object]("") // crash 

Output (click arrow to expand)

exception occurred while typechecking /Users/wmazur/projects/dotty/bisect/main.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: /Users/wmazur/projects/dotty/bisect/main.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-git-13a71ef
            settings: -classpath /Users/wmazur/.ivy2/local/org.scala-lang/scala3-library_3/3.4.0-RC1-bin-SNAPSHOT/jars/scala3-library_3.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -d /Users/wmazur/projects/dotty/bisect/.scala-build/bisect_1983f628ca-3fe1fc2157/classes/main -java-output-version 17 -source 3.4-migration -sourceroot /Users/wmazur/projects/dotty/bisect

Exception in thread "main" java.util.NoSuchElementException: head of empty list
        at scala.collection.immutable.Nil$.head(List.scala:662)
        at scala.collection.immutable.Nil$.head(List.scala:661)
        at dotty.tools.dotc.typer.Migrations.contextBoundParams(Migrations.scala:115)
        at dotty.tools.dotc.typer.Migrations.contextBoundParams$(Migrations.scala:28)
        at dotty.tools.dotc.typer.Typer.contextBoundParams(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.adaptToArgs$1(Typer.scala:3776)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4360)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3679)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:956)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1116)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:350)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:120)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3114)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3198)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.addImplicitArgs$1(Typer.scala:3911)
        at dotty.tools.dotc.typer.Typer.adaptNoArgsImplicitMethod$1(Typer.scala:3929)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4129)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4365)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3679)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1670)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1660)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1670)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1932)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1932)
        at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1940)
        at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1958)
        at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1959)
        at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1970)
        at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1708)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1714)
        at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1812)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:800)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:943)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:823)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:174)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:189)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:191)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3061)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3086)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2789)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3102)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3106)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3301)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3347)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2922)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3148)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3198)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3275)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3279)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3391)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:477)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        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$1(Run.scala:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:357)
        at dotty.tools.dotc.Run.compileSources(Run.scala:261)
        at dotty.tools.dotc.Run.compile(Run.scala:246)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:197)
        at dotty.tools.dotc.Driver.process(Driver.scala:165)
        at dotty.tools.dotc.Driver.process(Driver.scala:177)
        at dotty.tools.dotc.Driver.main(Driver.scala:207)
        at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions