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

incompatible_disallow_split_empty_separator: string.split shouldn't accept empty separator #7355

Closed
laurentlb opened this issue Feb 5, 2019 · 5 comments

Comments

@laurentlb
Copy link
Member

@laurentlb laurentlb commented Feb 5, 2019

From https://github.com/bazelbuild/starlark/blob/master/spec.md#string%C2%B7split

"If sep is the empty string, split fails."

Yet:

% src/main/java/com/google/devtools/skylark/Skylark
>> "abc".split("")
.. 
["a", "b", "c", ""]

Compare:

% python2
>>> "abc".split("")
ValueError: empty separator

% python3
>>> "abc".split("")
ValueError: empty separator

% starlark  # go.starlark.net
>>> "abc".split("")
Error: split: empty separator

When the flag incompatible_disallow_split_empty_separator is set to true, string.split requires a separator. The default will be true with Bazel 1.0.

Fix:

Use string.elems instead.

@laurentlb

This comment has been minimized.

Copy link
Member Author

@laurentlb laurentlb commented Jul 8, 2019

cc @Quarz0 - want to send a PR?

Quarz0 added a commit to Quarz0/bazel that referenced this issue Jul 11, 2019
When enabled, string.split will fail if `sep` is the empty string.
RELNOTES: Flag `--incompatible_disallow_split_empty_separator` is added. See bazelbuild#7355
bazel-io pushed a commit that referenced this issue Jul 11, 2019
Related: #7355 #8726

Closes #8836.

PiperOrigin-RevId: 257614252
irengrig added a commit to irengrig/bazel that referenced this issue Jul 15, 2019
@laurentlb laurentlb changed the title string.split accepts invalid empty separator incompatible_disallow_split_empty_separator: string.split shouldn't accept empty separator Jul 24, 2019
@katre katre removed the migration-ready label Aug 2, 2019
@dslomov

This comment has been minimized.

Copy link
Contributor

@dslomov dslomov commented Aug 5, 2019

Is there migration tooling? What is the extent of breakage?

@laurentlb

This comment has been minimized.

Copy link
Member Author

@laurentlb laurentlb commented Aug 5, 2019

Breakages are expected to be extremely rare. There's only one occurrence of it in all of Google code base.

It's not worth writing a tool for this.

@dslomov

This comment has been minimized.

Copy link
Contributor

@dslomov dslomov commented Aug 5, 2019

@laurentlb

This comment has been minimized.

Copy link
Member Author

@laurentlb laurentlb commented Aug 27, 2019

Flipped in 67cc426

@laurentlb laurentlb closed this Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.