On 02/10/12 19:07, H. S. Teoh wrote: > I'm not sure whether the following a compiler/language bug or a Phobos > bug, but it's definitely some kind of bug: > > auto s = "abc"; > immutable t = "def"; > > writeln(typeid(s)); // immutable(char)[] > writeln(typeid(t)); // immutable(immutable(char)[]) > // (what is this supposed to mean?!)
The array itself is immutable, not just the elements. > char ch = 'c'; > bool b = canFind(s, ch); // OK > bool c = canFind(t, ch); // Compile error?? > > The compile error is: > > test.d:11: Error: template std.algorithm.canFind(alias pred = "a == > b",Range,V) if (is(typeof(find!(pred)(range,value)))) does not match any > function template declaration > test.d:11: Error: template std.algorithm.canFind(alias pred = "a == > b",Range,V) if (is(typeof(find!(pred)(range,value)))) cannot deduce template > function from argument types !()(immutable(char[]),char) > > Can somebody explain what's going on here? FWIW, it compiles fine here. artur