Skip to content

Commit

Permalink
Define vector_any in coreimg.
Browse files Browse the repository at this point in the history
This enables calls to kwarg functions before Base is defined
(eg. in inference), as the frontend generates a call to vector_any.

(cherry picked from commit 95c26b5)
ref #18396

Add a test for #18396.

Call a kwarg function in Core.Inference where vector_any was unavailable.

(cherry picked from commit fab9560)
  • Loading branch information
maleadt authored and tkelman committed Feb 15, 2017
1 parent a97fbda commit 1bbc846
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 @@ -209,3 +209,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 @@ -218,3 +218,10 @@ end
@test f9948(x=5) == 5
@test_throws UndefVarError f9948()
@test getx9948() == 3

# 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 1bbc846

Please sign in to comment.