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

0-keyword argument funcalls fail #18845

Closed
cstjean opened this issue Oct 8, 2016 · 4 comments
Closed

0-keyword argument funcalls fail #18845

cstjean opened this issue Oct 8, 2016 · 4 comments
Assignees
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Comments

@cstjean
Copy link
Contributor

cstjean commented Oct 8, 2016

Follow-up to #14758. On 0.5.0

no_kwargs = Any[]
foo() = 10
@eval foo(; $(no_kwargs...))

> LoadError: function foo does not accept keyword arguments

Similarly:

type Something end
no_kwargs = Any[]
@eval Something(; $(no_kwargs...))

> LoadError: MethodError: no method matching Something()
@yuyichao
Copy link
Contributor

yuyichao commented Oct 8, 2016

Related to although not exactly dup of #9498

@cstjean
Copy link
Contributor Author

cstjean commented Oct 8, 2016

Is there a reason why f(args...; kwargs...) and f(args..., kwargs...) shouldn't be lowered to the same thing, in a function call?

@yuyichao
Copy link
Contributor

yuyichao commented Oct 8, 2016

Is there a reason why f(args...; kwargs...) and f(args..., kwargs...) shouldn't be lowered to the same thing, in a function call?

Yes, the kwargs in the second form are positional arguments.

Also.

julia> :(foo(; $(no_kwargs...)))
:(foo(; ))

julia> :(foo(; no_kwargs...))
:(foo(; no_kwargs...))

julia> expand(:(foo(; $(no_kwargs...))))
:(((Core.kwfunc)(foo))((Base.vector_any)(),foo))

julia> expand(:(foo(; no_kwargs...)))
:($(Expr(:thunk, CodeInfo(:(begin 
        SSAValue(0) = (Base.vector_any)()
        SSAValue(1) = no_kwargs
        #s2 = (Base.start)(SSAValue(1))
        4: 
        unless !((Base.done)(SSAValue(1),#s2)) goto 19
        SSAValue(2) = (Base.next)(SSAValue(1),#s2)
        SSAValue(3) = (Core.getfield)(SSAValue(2),1)
        #temp# = (Base.start)(SSAValue(3))
        SSAValue(4) = (Base.indexed_next)(SSAValue(3),1,#temp#)
        SSAValue(5) = (Core.getfield)(SSAValue(4),1)
        #temp# = (Core.getfield)(SSAValue(4),2)
        SSAValue(6) = (Base.indexed_next)(SSAValue(3),2,#temp#)
        SSAValue(7) = (Core.getfield)(SSAValue(6),1)
        #temp# = (Core.getfield)(SSAValue(6),2)
        #s2 = (Core.getfield)(SSAValue(2),2)
        (Core.ccall)(:jl_array_ptr_1d_push2,Void,(Core.svec)(Any,Any,Any),SSAValue(0),0,(Core.typeassert)(SSAValue(5),Core.Symbol),0,SSAValue(7),0)
        17: 
        goto 4
        19: 
        unless (Base.isempty)(SSAValue(0)) goto 22
        return foo()
        22: 
        return ((Core.kwfunc)(foo))(SSAValue(0),foo)
    end)))))

@cstjean
Copy link
Contributor Author

cstjean commented Oct 8, 2016

Oh, right, then my work-around is mistaken. Edited.

@JeffBezanson JeffBezanson self-assigned this Oct 10, 2016
@JeffBezanson JeffBezanson added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label Oct 10, 2016
JeffBezanson added a commit that referenced this issue Oct 10, 2016
fix #18845, call with 0 keyword args splatted after `;`
tkelman pushed a commit that referenced this issue Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

No branches or pull requests

3 participants