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

QuoteNode, LineNumberNode leaking into macros #23661

Closed
TotalVerb opened this issue Sep 11, 2017 · 5 comments
Closed

QuoteNode, LineNumberNode leaking into macros #23661

TotalVerb opened this issue Sep 11, 2017 · 5 comments
Assignees
Labels
macros @macros

Comments

@TotalVerb
Copy link
Contributor

julia> macro foo(ex)
           dump(ex)
       end
@foo (macro with 1 method)

julia> @foo :x
QuoteNode
  value: Symbol x

julia> @foo begin
           1
           2
       end
Expr
  head: Symbol block
  args: Array{Any}((4,))
    1: LineNumberNode
      line: Int64 2
      file: Symbol REPL[12]
    2: Int64 1
    3: LineNumberNode
      line: Int64 3
      file: Symbol REPL[12]
    4: Int64 2
  typ: Any

The behavior here is different than the previous behavior of passing these in as Expr(:quote) and Expr(:line). If this is an intended change (which would be unfortunate, in my opinion), then it should be documented in NEWS.

@TotalVerb
Copy link
Contributor Author

Probably related to #23533, cc @vtjnash

@vtjnash
Copy link
Member

vtjnash commented Sep 11, 2017

essentially a dup of #15310

@kmsquire kmsquire reopened this Sep 11, 2017
@kmsquire
Copy link
Member

Except that, presumably, #15310 didn't cause breakage in DataStructures.jl?

@JeffBezanson
Copy link
Member

I don't think it's a dup; that was about expressions returned from macros, while this is a change in what we pass to macros.

@JeffBezanson JeffBezanson self-assigned this Sep 26, 2017
JeffBezanson added a commit that referenced this issue Sep 26, 2017
We no longer use the `:line` Expr head in julia.
JeffBezanson added a commit that referenced this issue Sep 26, 2017
We no longer use the `:line` Expr head in julia.
JeffBezanson added a commit that referenced this issue Sep 27, 2017
We no longer use the `:line` Expr head in julia.
@JeffBezanson
Copy link
Member

After exploring this, it seems we've been using QuoteNode and LineNumberNode quite a bit. Trying to eliminate them from macro arguments actually required more code changes, so we'll keep the new behavior. It's in the ast devdocs, but the summary is that QuoteNode is used for quoted atoms (e.g. symbols) and LineNumberNode is used for all line number info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macros @macros
Projects
None yet
Development

No branches or pull requests

4 participants