Do-block syntax with keyword arguments

Is is possible to use the do syntax with keyword arguments? MWE:

just_call(f, args...; kwargs...) = f(args...; kwargs...)

# lambda
just_call((x; z) -> @show(x, z), 1; z = 2)

# do
just_call(1; z = 2) do x; z
    @show x, z
end

but the latter fails with

ERROR: MethodError: no method matching (::var"#20#21")(::Int64; z::Int64)

Closest candidates are:
  (::var"#20#21")(::Any) got unsupported keyword argument "z"
   @ Main REPL[30]:1

The manual does not talk about this, and I could not find an open issue.

5 Likes

Opened an issue

Surprising that this has not crop up before, but now I think that most methods in Base (if not all) that have the first parameter as a function do not pass anything as keyword argument to them.