-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix interpretation of Typed trees #3852
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
Fix interpretation of Typed trees #3852
Conversation
4882723
to
ef22a87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -111,10 +111,13 @@ class Interpreter(implicit ctx: Context) { | |||
val env2 = bindings.foldLeft(env)((acc, x) => interpretStat(x, acc)) | |||
interpretTreeImpl(expansion, env2) | |||
|
|||
case Typed(expr, _) => | |||
interpretTreeImpl(expr, env) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a check here? Maybe not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of check? This is a fully typed tree, we evaluate it's erased version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to check the type, but it's not the semantics of the language. So ignore the comment.
@@ -0,0 +1,2 @@ | |||
true | |||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I be sure the output is from compile-time, not run-time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the inline def
has a top level ~
it can always be inlined. Then the inlined tree is interpreted to evaluate the Expr[T]
which is then spliced in (see #3853 for a bit of info on that regard).
In short a macro call is guaranteed to be inlined or the compilation fails.
Thanks for the explanation, it makes sense. Move the code to a uncalled
method can also remove any doubt.
Le 17 janv. 2018 6:30 PM, "Nicolas Stucki" <[email protected]> a
écrit :
… ***@***.**** commented on this pull request.
------------------------------
In tests/run/quote-splice-interpret-1.check
<#3852 (comment)>:
> @@ -0,0 +1,2 @@
+true
+false
Because the inline def has a top level ~ it can always be inlined. Then
the inlined tree is interpreted to evaluate the Expr[T] which is then
spliced in (see #3853 <#3853> for
a bit of info on that regard).
In short a macro call is guaranteed to be inlined or the compilation fails.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#3852 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAuDyQ_-Kpw07bAGSdCm3P225hqRJGkmks5tLi5NgaJpZM4RgAvk>
.
|
It is only when inlining a |
I mean in the test it's possible to move |
No description provided.