D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4933 - canFind() does not work with const or immutable strings
Summary: canFind() does not work with const or immutable strings
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-23 22:35 UTC by Jonathan M Davis
Modified: 2015-06-09 05:14 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 Jonathan M Davis 2010-09-23 22:35:07 UTC
As of phobos revision 2032 or 2033 (2032 doesn't compile it seems, so I don't know which one the breaking changes are in), this no longer compiles:

import std.algorithm;
import std.ctype;

void main()
{
    immutable str = "1234567890";

    assert(!canFind!((c){return !isdigit(c);})(str));
}


If you change str to auto, then it works just fine. const and immutable, however, will no longer compile. My guess is that it has to do with the changes that David has been doing towards making phobos more const-correct, and so he's probably aware of the problem, but I figured that I might as well report the bug just in case. Regardless, I guess that I get to avoid using immutable strings for the time being...
Comment 1 Jonathan M Davis 2012-01-20 23:28:46 UTC
The recent IFTI changes making it so that arrays are treated as tail-const for IFTI fixes this issue.