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

clarify Expr changes in 1.10+ #51653

Open
Roger-luo opened this issue Oct 10, 2023 · 0 comments
Open

clarify Expr changes in 1.10+ #51653

Roger-luo opened this issue Oct 10, 2023 · 0 comments
Labels
needs news A NEWS entry is required for this change parser Language parsing and surface syntax

Comments

@Roger-luo
Copy link
Contributor

I understand this change simplifies things a lot (I guess it's #46372), but I believe the behavior is a little bit breaking (because the AST is different across versions, e.g it's breaking Expronicon's unit tests) and perhaps should be mentioned somewhere in the NEWS.

in 1.10+

julia> ex = :(function (x::Int; kw=1) end)
:(function (x::Int,; kw = 1)
      #= REPL[1]:1 =#
      #= REPL[1]:1 =#
  end)

julia> ex.args[1].head
:tuple

julia> ex.args[1].args
2-element Vector{Any}:
 :($(Expr(:parameters, :($(Expr(:kw, :kw, 1))))))
 :(x::Int)

in 1.9-

julia> ex = :(function (x::Int; kw=1) end)
:(function x::Int, #= REPL[1]:1 =#, kw = 1
      #= REPL[1]:1 =#
      #= REPL[1]:1 =#
  end)

julia> ex.args[1].head
:block

julia> ex.args[1].args
3-element Vector{Any}:
 :(x::Int)
 :(#= REPL[1]:1 =#)
 :(kw = 1)

I'm not sure we have somewhere to clarify what the AST should look like, ideally in some formal way, tbh This causes trouble for people working on macros quite often. Now with JuliaSyntax, it's probably easier to have a piece of doc for this? PS. I remember there was an issue about this somewhere, but I don't remember which one it is.

@ViralBShah ViralBShah added the needs news A NEWS entry is required for this change label Oct 10, 2023
@vtjnash vtjnash added the parser Language parsing and surface syntax label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs news A NEWS entry is required for this change parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants