Skip to content

Phase inconsistency for quoted references #3898

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
nicolasstucki opened this issue Jan 24, 2018 · 1 comment
Closed

Phase inconsistency for quoted references #3898

nicolasstucki opened this issue Jan 24, 2018 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 24, 2018

When inlining the following ff macro, the varargs args is lifted out into a val which breaks phase consistency as takes it out of a quote.

import scala.quoted._
object Macro {
  inline def ff(args: Any*): String = ~impl('(args))
  def impl(args: Expr[Seq[Any]]): Expr[String] = ""
}
object Test {
  def main(args: Array[String]): Unit = {
    val x = 5
    Macro.ff(x)
  }
}

When inlined the code is

/* inlined from Macro*/ 
  {
    val args: Any* = [x : Any]: Any*
    Macro.impl(<special-ops>.'[Seq[Any] @Repeated](args)).unary_~
  }

and interpreted as to heal some phase inconsistencies

/* inlined from Macro*/ 
  {
    val args: Any* = [x : Any]: Any*
    Macro.impl(<special-ops>.'[Seq[Any] @Repeated](args))
  }.unary_~

Tis fails due to the x wich should be ouside the unary_~ or inside the <special-ops>.'

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jan 24, 2018
liufengyun pushed a commit to dotty-staging/dotty that referenced this issue Jan 26, 2018
liufengyun pushed a commit to dotty-staging/dotty that referenced this issue Jan 27, 2018
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Feb 16, 2018

This issue does not only happen with varargs.

import scala.quoted._
object Macro {
  inline def ff(x: Int): String = ~impl('(x))
  def impl(x: Expr[Int]): Expr[String] = ""
}
object Test {
  def main(args: Array[String]): Unit = {
    def x: Int = 5
    Macro.ff(x)
  }
}

Produces and fails for the same reason with

/* inlined from Macro*/ 
  {
    val x: Int = x
    Macro.impl(<special-ops>.'[Int](x)).unary_~
  }

interpreted as

/* inlined from Macro*/ 
  {
    val x: Int = x
    Macro.impl(<special-ops>.'[Int](x))
  }.unary_~

@nicolasstucki nicolasstucki changed the title Phase inconsistency for quoted varargs Phase inconsistency for quoted references Feb 16, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 20, 2018
nicolasstucki added a commit that referenced this issue Feb 21, 2018
Fix #3898: Do not interpret bindings for inlined parameters
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2020
This Inlined node not was added as part of a fix for issue scala#3898.
It was an ad-hoc patch that ended up causing more issues than fixes and
therfore is removed.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 3, 2020
This Inlined node not was added as part of a fix for issue scala#3898.
It was an ad-hoc patch that ended up causing more issues than fixes and
therfore is removed.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 5, 2020
This Inlined node not was added as part of a fix for issue scala#3898.
It was an ad-hoc patch that ended up causing more issues than fixes and
therfore is removed.
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

1 participant