D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6428 - Inconsistent implement in std.array.replaceFirst
Summary: Inconsistent implement in std.array.replaceFirst
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-02 06:55 UTC by Heromyth
Modified: 2011-08-22 01:03 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 Heromyth 2011-08-02 06:55:12 UTC
Test code:
    string s1 = "abc bcf";

    string s2 = s1.replaceFirst("bc", "ee");
    writefln("%s\n%s", s1, s2);

The s2 should be "aee bcf", however the result of replaceFirst is "aee".
Comment 1 Heromyth 2011-08-02 07:01:13 UTC
I have a patch:

--- array.d	Sun Jul 10 13:19:30 2011
+++ array-new.d	Tue Aug 02 21:58:12 2011
@@ -1522,7 +1522,7 @@
     auto app = appender!R1();
     app.put(subject[0 .. subject.length - balance.length]);
     app.put(to.save);
-    subject = balance[from.length .. $];
+    app.put(balance[from.length .. $]);
 
     return app.data;
 }