D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11702 - std.string.splitLines to immutable result
Summary: std.string.splitLines to immutable result
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-07 05:53 UTC by bearophile_hugs
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-12-07 05:53:19 UTC
void main() pure {
    import std.string;
    immutable parts = "5\n6".splitLines;
}


splitLines can be used in a pure function, but its result can't yet be assigned to an immutable (dmd 2.065alpha):

temp.d(3): Error: cannot implicitly convert expression (splitLines("5\x0a6", cast(KeepTerminator)false)) of type string[] to immutable(char[][])


Even this fails with a similar error:

void main() pure {
    import std.string;
    immutable s = "5\n6";
    immutable parts = s.splitLines;
}