Skip to content

Exception when running inner quote #4730

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
biboudis opened this issue Jun 27, 2018 · 0 comments
Closed

Exception when running inner quote #4730

biboudis opened this issue Jun 27, 2018 · 0 comments

Comments

@biboudis
Copy link
Contributor

biboudis commented Jun 27, 2018

import scala.quoted._

object Test {
  implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
  val ret: Expr[Int => Int] = '{ (x: Int) => ${ val z = run('{x + 1}); z.toExpr } }
  def main(args: Array[String]): Unit = {
    println(run(ret).apply(10))
  }
}

fails when running with:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at dotty.tools.vulpix.ChildJVMMain.runMain(ChildJVMMain.java:40)
	at dotty.tools.vulpix.ChildJVMMain.main(ChildJVMMain.java:47)
Caused by: java.lang.IllegalArgumentException: Could not find proxy for x: Int in List(val x, method $anonfun, method apply, class Generated$Code$From$Quoted, module class <root>), encl = method apply, owners = method apply, class Generated$Code$From$Quoted, package <root>; enclosures = method apply, class Generated$Code$From$Quoted, package <root>
	at dotty.tools.dotc.transform.LambdaLift$Lifter.searchIn$1(LambdaLift.scala:381)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.proxy(LambdaLift.scala:394)
	at dotty.tools.dotc.transform.LambdaLift$Lifter.proxyRef(LambdaLift.scala:412)
	at dotty.tools.dotc.transform.LambdaLift.transformIdent(LambdaLift.scala:526)
	at dotty.tools.dotc.transform.MegaPhase.goIdent(MegaPhase.scala:551)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:225)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:228)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:270)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformTrees$$anonfun$1(MegaPhase.scala:420)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at dotty.tools.dotc.transform.MegaPhase.transformTrees(MegaPhase.scala:420)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:271)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:245)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:248)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
	at dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:404)
	at dotty.tools.dotc.transform.MegaPhase.$anonfun$1(MegaPhase.scala:409)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:409)
	at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:339)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:396)
	at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:251)
	at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:394)
@nicolasstucki nicolasstucki changed the title Exception when classloading inner quote after running it Exception when running inner quote Jun 20, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 7, 2019
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 7, 2019
liufengyun added a commit that referenced this issue Aug 19, 2019
Fix #4730,#6992: Detect scope extrusions in `quoted.run` and fail-fast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants