On Tuesday, 23 October 2012 at 04:51:01 UTC, timotheecour wrote:
void main() {
    //BigInt[] data1 = [5, 6, 9];
    auto data1 = [5, 6, 9].map!(a=>BigInt(a)).array;
    Ranged!(int,5,10)[] data2 = [5, 6, 9];
    auto data2 = [5, 6, 9].map!(a=>Ranged!(int,5,10)).array;
}


Syntax construct a=>b causes nasty bug covered up by map template. It is related to 8854, 8832 and 7978 and several topics at forum associated with these issues (strange behavior using map together with delegates).

The problem is that typeless undeclared identifier "a" causes syntax construct a=>b to be of type void rather than delegate. Once syntax is fixed, type of expression becomes as expected http://dpaste.dzfl.pl/738f7301

Sometimes this leads to observable incorrect behavior, sometimes not.

For example, if you have
-----main.d--------------
version (bug)
{
        import std.string;
}

import test;

void main()
{
        testfun();
}
-------test.d-----------------
import std.algorithm;
import std.stdio;

void testfun()
{
        int c = 0;
        writeln([0].map!(a=>c)[0]);
}
-----------------------------
then the behavior of program would depend on whether bug version is set or not.

Reply via email to