Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow calls to kwarg functions before Base is defined. #18396

Merged
merged 2 commits into from
Sep 14, 2016
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Sep 7, 2016

Used in #18338. Couldn't find a way to test..

@vtjnash
Copy link
Member

vtjnash commented Sep 9, 2016

yes, any (top) function should be defined in any top module that might use them, including Core.Inference; and essentials.jl is a good place for it.

for testing, you could use some variant of:

julia> eval(Core.Inference, quote
         f(;x...) = println(;x...)
       end)
f (generic function with 1 method)

julia> Core.Inference.f(a=1, b=2, c=3)
ERROR: UndefVarError: vector_any not defined
 in #f#213(::Array{Any,1}, ::Function) at REPL[1]:2
 in (::Core.Inference.#kw##f)(::Array{Any,1}, ::Core.Inference.#f) at <missing>:0
 in eval(::Module, ::Any) at ./boot.jl:234
 in eval(::Module, ::Any) at /Volumes/Lion/Users/jameson/Documents/julia/usr/lib/julia/sys.dylib:?
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at REPL.jl:66
 in macro expansion; at REPL.jl:97 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at event.jl:68

This enables calls to kwarg functions before Base is defined
(eg. in inference), as the frontend generates a call to vector_any.
maleadt added a commit that referenced this pull request Sep 13, 2016
Call a kwarg function in Core.Inference where vector_any was unavailable.
@maleadt maleadt added regression Regression in behavior compared to a previous version backport pending 0.5 labels Sep 13, 2016
@maleadt
Copy link
Member Author

maleadt commented Sep 13, 2016

Thanks. Turns out this did work on 0.4, so I've added the regression label.
Rebased and added a test.

f18396(;kwargs...) = g18396(;kwargs...)
g18396(;x=1,y=2) = x+y
end)
Core.Inference.f18396()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to also @test the return value so that it is also confirmed to do something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated.

@StefanKarpinski StefanKarpinski added this to the 0.5.x milestone Sep 13, 2016
maleadt added a commit that referenced this pull request Sep 13, 2016
Call a kwarg function in Core.Inference where vector_any was unavailable.
Call a kwarg function in Core.Inference where vector_any was unavailable.
@maleadt maleadt merged commit 71cb31a into master Sep 14, 2016
@tkelman tkelman deleted the tb/core_kwargs branch September 14, 2016 13:48
@tkelman
Copy link
Contributor

tkelman commented Sep 16, 2016

waiting until 0.5.1

tkelman pushed a commit that referenced this pull request Feb 22, 2017
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants