Skip to content

"assertion failed: unexpected top splice outside quote" when splicing & quoting multiple times #12173

Closed
@adamw

Description

@adamw

Compiler version

3.0.0-RC3

Minimized code

object TestMacro {
  inline def test[T](inline t: T): T = ${ '{ ${ 't } } }
}

object Test {
  TestMacro.test("x")
}

I know that splicing & quoting like this doesn't make much sense but this is a simplified example, and I think this should still work (or at least not give a compiler exception).

Output (click arrow to expand)

```scala [error] java.lang.AssertionError: assertion failed: unexpected top splice outside quote [error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transformSplice(PickleQuotes.scala:315) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:130) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:481) [error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:481) [error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1341) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:481) [error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60) [error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1421) [error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120) [error] dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90) [error] dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155) [error] dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510) [error] dotty.tools.dotc.transform.PickleQuotes$$anon$1.transform(PickleQuotes.scala:95) [error] dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21) [error] dotty.tools.dotc.transform.PickleQuotes.run(PickleQuotes.scala:91) [error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303) [error] scala.collection.immutable.List.map(List.scala:246) [error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304) [error] dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205) [error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15) [error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10) [error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323) [error] dotty.tools.dotc.Run.runPhases$5(Run.scala:215) [error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:223) [error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) [error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67) [error] dotty.tools.dotc.Run.compileUnits(Run.scala:230) [error] dotty.tools.dotc.Run.compileSources(Run.scala:166) [error] dotty.tools.dotc.Run.compile(Run.scala:150) [error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39) [error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88) [error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22) [error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91) [error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:186) [error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) [error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241) [error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:176) [error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:157) [error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239) [error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:157) [error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528) [error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:174) [error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:172) [error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:457) [error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116) [error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56) [error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52) [error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261) [error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:412) [error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499) [error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:399) [error] sbt.internal.inc.Incremental$.apply(Incremental.scala:166) [error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528) [error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482) [error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332) [error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420) [error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137) [error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2346) [error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2303) [error] sbt.internal.io.Retry$.apply(Retry.scala:46) [error] sbt.internal.io.Retry$.apply(Retry.scala:28) [error] sbt.internal.io.Retry$.apply(Retry.scala:23) [error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31) [error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2299) [error] scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] sbt.std.Transform$$anon$4.work(Transform.scala:68) [error] sbt.Execute.$anonfun$submit$2(Execute.scala:282) [error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23) [error] sbt.Execute.work(Execute.scala:291) [error] sbt.Execute.$anonfun$submit$1(Execute.scala:282) [error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265) [error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64) [error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [error] java.base/java.lang.Thread.run(Thread.java:834) ```

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions