D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 16587 - split("", "x") should be []
Summary: split("", "x") should be []
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-03 22:08 UTC by Vladimir Panteleev
Modified: 2016-10-09 15:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2016-10-03 22:08:54 UTC
/////////////// test.d ///////////////
import std.string;

void main()
{
    assert("".split(",").length == 0);
}
//////////////////////////////////////

Introduced in https://github.com/dlang/phobos/pull/4030.

Additionally, the new behavior is inconsistent:

split("")          => []
split("", ",")     => [""]
splitLines("")     => []
Comment 1 Vladimir Panteleev 2016-10-03 22:10:55 UTC
Example real-life scenarios:

- Comma-delimited lists in program arguments or configuration files. The string variables will be empty unless populated, then split afterwards.

- `libPaths ~= environment.get("LIBPATH", null).split(":")` will now search the current directory.
Comment 2 github-bugzilla 2016-10-04 03:09:03 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d6572c2a44d69f449bfe2b07461b2f0a1d6503f9
Fix Issue 16587 - split("", "x") should be ""

This reverts commit b438bf5a0653b616ef6debe2a0dfe247d8fc5928.

https://github.com/dlang/phobos/commit/e3f842d52a3eedc7c8f6a5e75f26de05d5cf1fea
Merge pull request #4836 from CyberShadow/pull-20161003-223010

Fix Issue 16587 - split("", "x") should be ""
Comment 3 Andrei Alexandrescu 2016-10-04 13:25:51 UTC
Thanks, Vladimir!
Comment 4 github-bugzilla 2016-10-09 15:38:10 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/d6572c2a44d69f449bfe2b07461b2f0a1d6503f9
Fix Issue 16587 - split("", "x") should be ""

https://github.com/dlang/phobos/commit/e3f842d52a3eedc7c8f6a5e75f26de05d5cf1fea
Merge pull request #4836 from CyberShadow/pull-20161003-223010