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

UnpackArgs has different behavior for args vs kwargs #544

Closed
nicks opened this issue May 6, 2024 · 2 comments · Fixed by #545
Closed

UnpackArgs has different behavior for args vs kwargs #544

nicks opened this issue May 6, 2024 · 2 comments · Fixed by #545

Comments

@nicks
Copy link
Contributor

nicks commented May 6, 2024

Repro steps:

  1. 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)
}
  1. Pass two arguments to this function as named args:
f(1, 2)

This is OK.

  1. 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.

nicks added a commit to tilt-dev/starlark-go that referenced this issue May 6, 2024
nicks added a commit to tilt-dev/starlark-go that referenced this issue May 6, 2024
Fixes google#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to tilt-dev/starlark-go that referenced this issue May 6, 2024
Fixes google#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to tilt-dev/starlark-go that referenced this issue May 6, 2024
Fixes google#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
@adonovan
Copy link
Collaborator

adonovan commented May 6, 2024

Did you mean starlark.UnpackArgs("unpack", args, kwargs, ...?

@nicks
Copy link
Contributor Author

nicks commented May 6, 2024

oops, yes, fixed!

nicks added a commit to tilt-dev/starlark-go that referenced this issue May 7, 2024
Fixes google#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
adonovan pushed a commit that referenced this issue May 7, 2024
Fixes #544

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to tilt-dev/tilt that referenced this issue May 14, 2024
pulls in fixes to google/starlark-go#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to tilt-dev/tilt that referenced this issue May 15, 2024
pulls in fixes to google/starlark-go#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to tilt-dev/tilt that referenced this issue May 15, 2024
pulls in fixes to google/starlark-go#544

Signed-off-by: Nick Santos <nick.santos@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants