Skip to content

clarify Expr changes in 1.10+ #51653

@Roger-luo

Description

@Roger-luo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs newsA NEWS entry is required for this changeparserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions