Skip to content

Commit 8da820c

Browse files
committed
No interface change necessary?
1 parent fb9f6c6 commit 8da820c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/utils.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ end
408408
function combinearg(arg_name, arg_type, is_splat, default)
409409
@assert arg_name !== nothing || arg_type !== nothing
410410
a = arg_name===nothing ? :(::$arg_type) :
411-
arg_type===nothing ? arg_name :
411+
arg_type==:Any ? arg_name :
412412
:($arg_name::$arg_type)
413413
a2 = is_splat ? Expr(:..., a) : a
414414
return default === nothing ? a2 : Expr(:kw, a2, default)
@@ -418,16 +418,16 @@ end
418418
splitarg(arg)
419419
420420
Match function arguments (whether from a definition or a function call) such as
421-
`x::Int=2` and return `(arg_name, arg_type, is_splat, default)`. `arg_name`,
422-
`arg_type`, and `default` are `nothing` when they are absent. For example:
421+
`x::Int=2` and return `(arg_name, arg_type, is_splat, default)`. `arg_name` and
422+
`default` are `nothing` when they are absent. For example:
423423
424424
```julia
425425
julia> map(splitarg, (:(f(a=2, x::Int=nothing, y, args...))).args[2:end])
426426
4-element Array{Tuple{Symbol,Symbol,Bool,Any},1}:
427-
(:a, nothing, false, 2)
427+
(:a, :Any, false, 2)
428428
(:x, :Int, false, :nothing)
429429
(:y, :Any, false, nothing)
430-
(:args, nothing, true, nothing)
430+
(:args, :Any, true, nothing)
431431
```
432432
433433
See also: [`combinearg`](@ref)
@@ -443,7 +443,7 @@ function splitarg(arg_expr)
443443
(arg_name, arg_type) = (@match arg_expr3 begin
444444
::T_ => (nothing, T)
445445
name_::T_ => (name, T)
446-
x_ => (x, nothing)
446+
x_ => (x, :Any)
447447
end)::NTuple{2,Any} # the pattern `x_` matches any expression
448448
return (arg_name, arg_type, is_splat, default)
449449
end

test/split.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ let
2727
@test longdef(:(f(x::T) where U where T = 2)).head == :function
2828
@test shortdef(:(function f(x)::Int 10 end)).head != :function
2929
@test map(splitarg, (:(f(a=2, x::Int=nothing, y::Any, args...))).args[2:end]) ==
30-
[(:a, nothing, false, 2), (:x, :Int, false, :nothing),
31-
(:y, :Any, false, nothing), (:args, nothing, true, nothing)]
30+
[(:a, :Any, false, 2), (:x, :Int, false, :nothing),
31+
(:y, :Any, false, nothing), (:args, :Any, true, nothing)]
3232
@test splitarg(:(::Int)) == (nothing, :Int, false, nothing)
3333
kwargs = splitdef(:(f(; a::Int = 1, b...) = 1))[:kwargs]
3434
@test map(splitarg, kwargs) ==
35-
[(:a, :Int, false, 1), (:b, nothing, true, nothing)]
35+
[(:a, :Int, false, 1), (:b, :Any, true, nothing)]
3636
args = splitdef(:(f(a::Int = 1) = 1))[:args]
3737
@test map(splitarg, args) == [(:a, :Int, false, 1)]
3838
args = splitdef(:(f(a::Int ... = 1) = 1))[:args]

0 commit comments

Comments
 (0)