DDT-IDE / DDT

DDT is an Eclipse-based IDE for the D programming language:
http://ddt-ide.github.io/
101 stars 16 forks source link

Reduced eponymous template syntax bug #135

Closed mleise closed 8 years ago

mleise commented 8 years ago

This compiles, but has several red markers all over it:

private immutable twoDigitsInBase(uint base, char code = char.init) = {
    static if (code == 'X')
        alias digits = std.ascii.hexDigits;
    else
        alias digits = std.ascii.lowerHexDigits;

    char[2][base * base] result;
    uint i = 0;
    foreach (first; 0 .. base)
        foreach (second; 0 .. base)
            result[i++] = [digits[first], digits[second]];
    return result;
}();
bruno-medeiros commented 8 years ago

Even more simple:

immutable twoDigitsInBase(uint base) = { 123 , 1232 } ;
mleise commented 8 years ago

I deliberately didn't reduce the actual code to ensure the fix would cover all red markers in case some of them are not just consecutive faults. (It was the first time I retried DDT after a long period of using Mono-D.)

bruno-medeiros commented 8 years ago

Fair enough :+1: . Although from what I see the only bug here is that variables can be templated as well with the eponymous template syntax, and I didn't know that was possible in D (therefore the parser didn't support it). It wasn't in the D grammar before, but it is now.