Bug 6428 – Inconsistent implement in std.array.replaceFirst
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-08-02T06:55:00Z
Last change time
2011-08-22T01:03:33Z
Assigned to
nobody
Creator
bitworld
Comments
Comment #0 by bitworld — 2011-08-02T06:55:12Z
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 by bitworld — 2011-08-02T07:01:13Z
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;
}