UnpackArgs has different behavior for `args` vs `kwargs`
nicks opened this issue · comments
Repro steps:
- Define a built-in function with UnpackArgs used like this:
if err := starlark.UnpackArgs("unpack", args, kwargs,
"x", &x, "y?", &y, "z", &z); err != nil {
t.Errorf("UnpackArgs failed: %v", err)
}
- Pass two arguments to this function as named args:
f(1, 2)
This is OK.
- Pass two arguments to this function as positional args:
f(x=1, y=2)
Expected result:
This should succeed. y
is optional, so z
should also be optional
Actual result:
UnpackArgs failed: unpack: missing argument for z
Additional info
I have a test in a branch that demonstrates the problem, might also open a PR if the fix is easy.
Did you mean starlark.UnpackArgs("unpack", args, kwargs, ...
?
oops, yes, fixed!