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

string split/rsplit do not accept named parameters #14309

Closed
nanaze opened this issue Nov 23, 2021 · 3 comments
Closed

string split/rsplit do not accept named parameters #14309

nanaze opened this issue Nov 23, 2021 · 3 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel type: bug

Comments

@nanaze
Copy link

nanaze commented Nov 23, 2021

Python strings accept named parameters for the string.strip/rstrip functions

$ python3
>>> "a-b-c-d".split("-", maxsplit=2)
['a', 'b', 'c-d']
>>> "a-b-c-d".rsplit("-", maxsplit=2)
['a-b', 'c', 'd']
>>> 

I was surprised that this failed when used in a .bzl file

adding the following to src/test/java/net/starlark/java/eval/testdata/string_split.star will cause the test to fail

assert_eq("a-b-c-d".split("-", maxsplit=2), ["a", "b", "c-d"])
assert_eq("a-b-c-d".rsplit("-", maxsplit=2),  ["a-b", "c", "d"]);

error:

Error in split: split() got named argument for positional-only parameter 'maxsplit'

Marking these methods as "named" in src/main/java/net/starlark/java/eval/StringModule.java fixes the problem.

I have a Google-internal demonstration change at go/kvlhy

@gregestren gregestren added team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel type: bug untriaged labels Nov 23, 2021
@brandjon
Copy link
Member

brandjon commented Dec 2, 2021

Looks like we don't say in the spec whether maxsplit is a named param. Filed bazelbuild/starlark#210.

@brandjon brandjon added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Dec 2, 2021
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 27, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Starlark-Interpreter Issues involving the Starlark interpreter used by Bazel type: bug
Projects
None yet
Development

No branches or pull requests

3 participants