From 95c26b51bfc6967234b2e05319c96003cbc1e330 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 7 Sep 2016 15:05:02 -0400 Subject: [PATCH 1/2] Define vector_any in coreimg. This enables calls to kwarg functions before Base is defined (eg. in inference), as the frontend generates a call to vector_any. --- base/base.jl | 10 ---------- base/essentials.jl | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/base/base.jl b/base/base.jl index 9fa8d77cb4a15..65ea7d517bb8d 100644 --- a/base/base.jl +++ b/base/base.jl @@ -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 diff --git a/base/essentials.jl b/base/essentials.jl index 75fa67251fa56..0363f7a525d1c 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -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 From fab9560f1f6069bc37368f593d5177125a6c8c53 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 13 Sep 2016 15:26:16 -0400 Subject: [PATCH 2/2] Add a test for #18396. Call a kwarg function in Core.Inference where vector_any was unavailable. --- test/keywordargs.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/keywordargs.jl b/test/keywordargs.jl index 706a3a326a6e0..aa58b0aa487fc 100644 --- a/test/keywordargs.jl +++ b/test/keywordargs.jl @@ -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