[phobos] bug in map
Dmitry Olshansky
dmitry.olsh at gmail.com
Fri Aug 17 02:14:18 PDT 2012
On 06-Aug-12 22:55, Andrei Alexandrescu wrote:
> Consider:
>
> auto s = "some string";
> static assert(!hasLength(typeof(s));
> auto m = map!(a => a)(s);
> static assert(!hasLength(typeof(s));
>
> Both asserts should pass: string famously has a length that's actually
> not the length of the range. Then mapping something on top of the
> string should also have no meaningful length. Alas, it does, because
> of the following code in std.algorithm:
>
> static if (hasLength!R || isSomeString!R)
> {
> @property auto length()
> {
> return _input.length;
> }
> alias length opDollar;
> }
>
> The code used to introduce length only if if (hasLength!R).
>
> It seems Kenji introduced this change. What was its purpose, and can
> we undo it? This breaks the entire web of
It bugs me - the indecision on this matter. No Kenji didn't introduce it.
The guilty commit (that could be reverted on it's own):
SHA-1: d0457fe82a5f140218d8a9700eb7c26a236d4abe
* This test is actually needed
Adds "isSomeString" to map's "length" test.
Author: monarchdodra
Contains one line diff that goes as follows:
-static if (hasLength!R)
+static if (hasLength!R || isSomeString!R)
P.S. I do not suggest to gill our new contributors but to pay more
attention during the review of pulls.
--
Olshansky Dmitry
More information about the phobos
mailing list