Bug 6191 – removechars doesn't accept a const string
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-06-21T10:56:00Z
Last change time
2012-04-24T19:15:02Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-06-21T10:56:03Z
DMD 2.053:
import std.string;
void main() {
const string s = "foo5x";
auto s2 = removechars(s, "^A-Z");
}
test.d(4): Error: template std.string.removechars(S) if (isSomeString!(S)) does not match any function template declaration
test.d(4): Error: template std.string.removechars(S) if (isSomeString!(S)) cannot deduce template function from argument types !()(const(immutable(char)[]),string)
(Additionally, removechars is not pure nothrow.)
Comment #1 by lovelydear — 2012-04-22T03:16:18Z
Compiles and runs fine on 2.059 Win32
Comment #2 by bearophile_hugs — 2012-04-24T19:15:02Z
import std.string, std.stdio;
void main() nothrow {
const string s = "foAo5x";
auto s2 = removechars(s, "^A-Z");
}
With dmd 2.060alpha it gives:
test.d(4): Error: removechars is not nothrow
test.d(2): Error: function D main 'main' is nothrow yet may throw
So removechars is not nothrow, but the main problem is fixed, so I close this issue.