408
408
function combinearg (arg_name, arg_type, is_splat, default)
409
409
@assert arg_name != = nothing || arg_type != = nothing
410
410
a = arg_name=== nothing ? :(:: $arg_type ) :
411
- arg_type=== nothing ? arg_name :
411
+ arg_type== :Any ? arg_name :
412
412
:($ arg_name:: $arg_type )
413
413
a2 = is_splat ? Expr (:... , a) : a
414
414
return default === nothing ? a2 : Expr (:kw , a2, default)
@@ -418,16 +418,16 @@ end
418
418
splitarg(arg)
419
419
420
420
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:
423
423
424
424
```julia
425
425
julia> map(splitarg, (:(f(a=2, x::Int=nothing, y, args...))).args[2:end])
426
426
4-element Array{Tuple{Symbol,Symbol,Bool,Any},1}:
427
- (:a, nothing , false, 2)
427
+ (:a, :Any , false, 2)
428
428
(:x, :Int, false, :nothing)
429
429
(:y, :Any, false, nothing)
430
- (:args, nothing , true, nothing)
430
+ (:args, :Any , true, nothing)
431
431
```
432
432
433
433
See also: [`combinearg`](@ref)
@@ -443,7 +443,7 @@ function splitarg(arg_expr)
443
443
(arg_name, arg_type) = (@match arg_expr3 begin
444
444
:: T_ => (nothing , T)
445
445
name_:: T_ => (name, T)
446
- x_ => (x, nothing )
446
+ x_ => (x, :Any )
447
447
end ):: NTuple{2,Any} # the pattern `x_` matches any expression
448
448
return (arg_name, arg_type, is_splat, default)
449
449
end
0 commit comments