Bug 4933 – canFind() does not work with const or immutable strings

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-09-23T22:35:00Z
Last change time
2015-06-09T05:14:49Z
Assigned to
andrei
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2010-09-23T22:35:07Z
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 by issues.dlang — 2012-01-20T23:28:46Z
The recent IFTI changes making it so that arrays are treated as tail-const for IFTI fixes this issue.