A function with keyword arguments creates a hidden helper function that places all the keyword arguments into a positional function call. Something vaguely like
function foo1(x, _, y; z)
z_positional = z
_foo1_internal(x, _, y, z_positional) # <-- the problem arises here
end
function _foo1_internal(x, _, y, z)
@show x,y,z
end
So the issue is that it isn’t being very smart with the helper function and is trying to forward the _
argument. This means it shows up as a value on the right hand side of a statement (“rvalue”) and you get the confusing error that you saw.
There’s an open issue for this #32727 but it hasn’t been addressed yet.