Skip to content
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

Quoted parameters not correctly checked in macros #12225

Closed
nicolasstucki opened this issue Apr 26, 2021 · 0 comments · Fixed by #14117
Closed

Quoted parameters not correctly checked in macros #12225

nicolasstucki opened this issue Apr 26, 2021 · 0 comments · Fixed by #14117

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.0.0-RC3

Minimized example

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

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

The outermost quote is supposed to only contain parameters or field references.

Output (click arrow to expand)

java.lang.AssertionError: assertion failed: unexpected top splice outside quote
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transformSplice(PickleQuotes.scala:315)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:130)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1437)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1437)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1333)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1341)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1367)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1410)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.recur$1(TreeMapWithImplicits.scala:35)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.recur$1(TreeMapWithImplicits.scala:41)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:54)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1421)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.TreeMapWithStages.mapOverTree$1(TreeMapWithStages.scala:90)
        at dotty.tools.dotc.transform.TreeMapWithStages.transform(TreeMapWithStages.scala:155)
        at dotty.tools.dotc.transform.PickleQuotes$QuoteReifier.transform(PickleQuotes.scala:510)
        at dotty.tools.dotc.transform.PickleQuotes$$anon$1.transform(PickleQuotes.scala:95)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
        at dotty.tools.dotc.transform.PickleQuotes.run(PickleQuotes.scala:91)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:303)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
        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.compileSources(Run.scala:166)
        at dotty.tools.dotc.Run.compile(Run.scala:150)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)

Expectation

Should emit an error.

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.

2 participants