D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6191 - removechars doesn't accept a const string
Summary: removechars doesn't accept a const string
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-06-21 10:56 UTC by bearophile_hugs
Modified: 2012-04-24 19:15 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 bearophile_hugs 2011-06-21 10:56:03 UTC
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 SomeDude 2012-04-22 03:16:18 UTC
Compiles and runs fine on 2.059 Win32
Comment 2 bearophile_hugs 2012-04-24 19:15:02 UTC
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.