julia
52e04af4 - fix: re-parsable printing of vararg anon func defs (#54019)

Commit
249 days ago
fix: re-parsable printing of vararg anon func defs (#54019) Currently, anonymous function definitions with one slurping argument are not printed in a re-parsable way: ``` julia> Meta.parse("(a...) -> a") :(a...->begin #= none:1 =# a end) julia> Meta.parse(repr(Meta.parse("(a...) -> a"))) ERROR: ParseError: # Error @ none:1:7 # ┌────── :(a...->begin #= none:1 =# a #─────────┘ ── Expected `)` Stacktrace: [1] #parse#3 @ ./meta.jl:244 [inlined] [2] parse @ ./meta.jl:236 [inlined] [3] parse(str::String; filename::String, raise::Bool, depwarn::Bool) @ Base.Meta ./meta.jl:278 [4] parse(str::String) @ Base.Meta ./meta.jl:276 [5] top-level scope @ REPL[2]:1 ``` This PR wraps the argument list in a `(:tuple, ...)`, much like what we are already doing for normal functions: ``` julia> Meta.parse("function (a...) end") :(function (a...,) #= none:1 =# #= none:1 =# end) ``` Technically neither of those are entirely correct (since they're not idempotent). A fix for that is more involved, but I can take a look at that as well if necessary. --------- Co-authored-by: Andy Dienes <51664769+adienes@users.noreply.github.com>
Author
Parents
Loading