Chaining in named arguments

I stumbled upon this when trying to debug something that had happened for a user:

foo(; x=1, y=1) = print("x: $x, y: $y") 
foo() # x: 1, y: 1
foo(; x=y=0) # x: 0, y: 1

initially I thought that the last one would just fail but it actually works, though, it seems to me, in a bit of counterintuitive way?

I’m not really looking for a solution, maybe just a comment as to why this is the case and whether this is desirable. IMO the chaining in arguments itself should maybe just fail but this might be more complex than I think.

cc @lazarusA

It’s just an issue of precedence. see

julia> t = :(foo(; x=y=0))
:(foo(; x = (y = 0)))

So the y keyword argument is never called.


Yeah, ditto what @pdeffebach said. Assignments are also expressions with a value, which is why we are able to do

a = b = 1