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
ast/compile: 'every' rewriting steps #4231
ast/compile: 'every' rewriting steps #4231
Conversation
0dc372c
to
9093e0c
Compare
ba17c25
to
3ecaaa5
Compare
there's a broken test I've got to take care of (not sure yet if the test is bogus or the code). moving to draft. |
3ecaaa5
to
ae3073e
Compare
if ev, ok := x.(*Every); ok { | ||
vis.Walk(ev.Body) | ||
return true | ||
} |
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.
This is a bit of a trap: WalkClosures
checks that its node in question is of type *Every. So, when passing a function, you get an x
of type *Every, and to walk its actual closure, the every.Body
, it'll have to be done like this.
I wonder if there's a better approach here. Having WalkClosures
apply f
to ev.Body
here would not allow us to differentiate what we've been called on when we need it, here.
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 think this is unavoidable due to the scoping rules we've implemented for every
. Presumably it'll be the same for any other keywords we add that support closures and local variable declaration. This seems like the best we can do.
069f2f2
to
8b299fd
Compare
LGTM! |
if ev, ok := x.(*Every); ok { | ||
vis.Walk(ev.Body) | ||
return true | ||
} |
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 think this is unavoidable due to the scoping rules we've implemented for every
. Presumably it'll be the same for any other keywords we add that support closures and local variable declaration. This seems like the best we can do.
7efbfda
to
68d318c
Compare
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
There's one broken test that I haven't figured out how to fix yet. From the perspective of topdown, this change felt right, it will simplify evaluation. Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
f0111c7
to
5f5da56
Compare
This PR covers the compiler doing it's job on
every
: