Skip to content

Commit

Permalink
Merge pull request #18396 from JuliaLang/tb/core_kwargs
Browse files Browse the repository at this point in the history
Allow calls to kwarg functions before Base is defined.
  • Loading branch information
maleadt authored Sep 14, 2016
2 parents 30bf89f + fab9560 commit 71cb31a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 0 additions & 10 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ finalize(o::ANY) = ccall(:jl_finalize_th, Void, (Ptr{Void}, Any,),
gc(full::Bool=true) = ccall(:jl_gc_collect, Void, (Cint,), full)
gc_enable(on::Bool) = ccall(:jl_gc_enable, Cint, (Cint,), on)!=0

# used by interpolating quote and some other things in the front end
function vector_any(xs::ANY...)
n = length(xs)
a = Array{Any}(n)
@inbounds for i = 1:n
arrayset(a,xs[i],i)
end
a
end

immutable Nullable{T}
isnull::Bool
value::T
Expand Down
10 changes: 10 additions & 0 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,13 @@ const (:) = Colon()
# For passing constants through type inference
immutable Val{T}
end

# used by interpolating quote and some other things in the front end
function vector_any(xs::ANY...)
n = length(xs)
a = Array{Any}(n)
@inbounds for i = 1:n
Core.arrayset(a,xs[i],i)
end
a
end
7 changes: 7 additions & 0 deletions test/keywordargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,10 @@ let opts = (:a=>3, :b=>4)
@test g17785(; opts..., a=5, b=6) == (5, 6)
@test g17785(; b=0, opts..., a=5) == (5, 4)
end

# pr #18396, kwargs before Base is defined
eval(Core.Inference, quote
f18396(;kwargs...) = g18396(;kwargs...)
g18396(;x=1,y=2) = x+y
end)
@test Core.Inference.f18396() == 3

0 comments on commit 71cb31a

Please sign in to comment.