Skip to content

Do not allow running Expr that came as macro arguments #4576

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

Merged
merged 2 commits into from
May 24, 2018

Conversation

nicolasstucki
Copy link
Contributor

It is too hard to ensure that the contents of the tree
can be pickled. It would be posible but the current ad-hoc
solution is too brittle and has no good usecases.

It is too hard to ensure that the contents of the tree
can be pickled. It would be posible but the current ad-hoc
solution is too brittle and has no good usecases.
@@ -50,9 +50,8 @@ object Exprs {
*
* May contain references to code defined outside this Expr instance.
*/
final class TreeExpr[Tree](val tree: Tree, pickle: => Expr[_]) extends quoted.Expr[Any] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the comment need to be sync up that this refers to a Tasty Expr tree.

case expr: TreeExpr[Tree] @unchecked =>
new QuoteDriver().run(expr.pickled, runSettings)
case expr: TastyTreeExpr[Tree] @unchecked =>
throw new scala.quoted.QuoteError("Can't run and scala.quoted.Expr coming from a macro argument")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment as is has a typo, so a fix can be "Cannot run a type scala.quoted.Expr" ...

However that error is thrown at the call site of an inline def. The f.run is invoked inside the macro body, so maybe we can rephrase into something the following maybe:

Cannot call an inline definition that runs an Expr that comes from a macro argument.

@biboudis biboudis assigned nicolasstucki and unassigned biboudis May 24, 2018
@nicolasstucki nicolasstucki merged commit c963249 into scala:master May 24, 2018
@allanrenucci allanrenucci deleted the disable-macro-quote-run branch May 24, 2018 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants