-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
On current master, if an anonymous function's body starts with parenthesis, then parsing treats the parenthesis body as a function argument and treats the actual argument list as (invalid) function name.
julia> function(a)
(a)
end
ERROR: ParseError:
# Error @ REPL[1]:1:9
function(a)
# └─┘ ── Invalid signature in function definition
Stacktrace:
[1] top-level scope
@ REPL:1This used to work just fine on older versions.
Note that this parsing was and is still new-line sensitive,
Old:
julia> function (a)(a)
end
a (generic function with 1 method)
julia> function (a::Int)(a)
end
ERROR: syntax: function argument name not unique: "a" around REPL[1]:1
Stacktrace:
[1] top-level scope
@ REPL[1]:1
julia> function (a)
(a)
end
#5 (generic function with 1 method)
julia> function (a::Int)
(a)
end
#8 (generic function with 1 method)New:
julia> function (a)(a)
end
a (generic function with 1 method)
julia> function (a::Int)(a)
end
ERROR: syntax: function argument name not unique: "a" around REPL[4]:1
Stacktrace:
[1] top-level scope
@ REPL[4]:1
julia> function (a)
(a)
end
ERROR: ParseError:
# Error @ REPL[5]:1:10
function (a)
# └─┘ ── Invalid signature in function definition
Stacktrace:
[1] top-level scope
@ REPL:1
julia> function (a::Int)
(a)
end
ERROR: ParseError:
# Error @ REPL[6]:1:10
function (a::Int)
# └──────┘ ── Invalid signature in function definition
Stacktrace:
[1] top-level scope
@ REPL:1This works on f5f4c01 but stops working on b9f40be so I assume it's caused by #59870 .
Not sure if the change was intentional but it does break a few packages.
https://github.com/bramtayl/Unzip.jl/blob/c239114b4b7faf71dab924c1832a11eaa0312d22/src/Unzip.jl#L144
https://github.com/FluxML/Zygote.jl/blob/35acbf3ef2b3ab7fbc5ba41cac04eab26ffe1759/src/lib/array.jl#L609
https://github.com/QuantumBFS/Yao.jl/blob/1f35b0320c2c6b4dd4d7e1343f94704486877e54/lib/YaoBlocks/src/autodiff/chainrules_patch.jl#L81
https://github.com/JuliaImages/ImageSegmentation.jl/blob/c6ba02673db9f29095d2d9915f21566d2d9f9830/src/core.jl#L352