From 1bbc846f6ff710def11e976c518e9b047779f02a Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 7 Sep 2016 15:05:02 -0400 Subject: [PATCH] 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. (cherry picked from commit 95c26b51bfc6967234b2e05319c96003cbc1e330) ref #18396 Add a test for #18396. Call a kwarg function in Core.Inference where vector_any was unavailable. (cherry picked from commit fab9560f1f6069bc37368f593d5177125a6c8c53) --- base/base.jl | 10 ---------- base/essentials.jl | 10 ++++++++++ test/keywordargs.jl | 7 +++++++ 3 files changed, 17 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 30b8d83148f46..6753cf0f254c4 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -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 diff --git a/test/keywordargs.jl b/test/keywordargs.jl index 8030e3dce0ee1..874c747581234 100644 --- a/test/keywordargs.jl +++ b/test/keywordargs.jl @@ -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