Skip to content

Even simple macros do not expand with capture checking #18855

Closed
@reftrans

Description

@reftrans

Compiler version

Scala compiler version 3.4.0-RC1-bin-SNAPSHOT-git-f91e5d8

Minimized code

macro.scala:

import scala.quoted.*
import scala.language.experimental.captureChecking

def impl()(using Quotes): Expr[Unit] = '{()}
inline def run(): Unit = ${impl()}

invoc.scala:

import scala.language.experimental.captureChecking
val x = run()

Output (click arrow to expand)

> ../dotty/bin/scalac macro.scala invoc.scala

  exception occurred while typechecking invoc.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: invoc.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-git-f91e5d8
            settings:


  Exception while compiling macro.scala, invoc.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: <no file>
        during phase: parser
                mode: Mode()
     library version: version 2.13.12
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-git-f91e5d8
            settings:

Exception in thread "main" java.lang.IndexOutOfBoundsException: 0 is out of bounds (min 0, max -1)
	at scala.collection.mutable.ArrayBuffer.apply(ArrayBuffer.scala:107)
	at dotty.tools.dotc.core.Contexts$.comparer(Contexts.scala:832)
	at dotty.tools.dotc.core.TypeComparer$.testSubType(TypeComparer.scala:3058)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4096)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4183)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4395)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3697)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3293)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3297)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3409)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2881)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3166)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3216)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3293)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3297)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3409)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:45)
	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:468)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:51)
	at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:97)
	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:98)
	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:71)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:357)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:267)
	at dotty.tools.dotc.Driver.finish(Driver.scala:58)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:38)
	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.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
	at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
	at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions