Skip to content
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

use QuoteNode and LineNumberNode consistently #23885

Merged
merged 1 commit into from
Sep 28, 2017
Merged

Conversation

JeffBezanson
Copy link
Member

There is a bit of confusion about when Exprs are used vs. specialized node types like QuoteNode and LineNumberNode. Typically we have used Exprs for ASTs, including all macro inputs and outputs. My original plan for this issue was to plug the "leak" of QuoteNodes into macros by going back to Exprs for all macro arguments. However, it turns out that QuoteNode and LineNumberNode have already leaked into quite a few places, such that it's much simpler to go the other way and just use them more consistently.

This removes a bunch of code since we now always represent line numbers with LineNumberNode instead of :line Exprs.

This will break code that only looks for :quote and :line expressions, but I believe a lot of uses already handle QuoteNode and LineNumberNode so it shouldn't be too bad in practice. For example, we have already been returning (perhaps by mistake) these node types from parse.

This "fixes" #23661 by making the new behavior official. The more uniform representation should be worth it.

@JeffBezanson JeffBezanson added breaking This change will break code macros @macros parser Language parsing and surface syntax labels Sep 26, 2017
@JeffBezanson
Copy link
Member Author

Also, this re-breaks #15310, since :line Exprs returned from macros will now be normalized to LineNumberNodes. I'm ok with that, since all use cases should just be made to work with our standard AST representation.

@@ -999,7 +999,7 @@ JL_CALLABLE(jl_f_invoke_kwsorter)
jl_expr_t *jl_exprn(jl_sym_t *head, size_t n)
{
jl_ptls_t ptls = jl_get_ptls_states();
jl_array_t *ar = n==0 ? (jl_array_t*)jl_an_empty_vec_any : jl_alloc_vec_any(n);
Copy link
Member

Choose a reason for hiding this comment

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

fix (simplify) jl_copy_ast also now

We no longer use the `:line` Expr head in julia.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code macros @macros parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants