DDT-IDE / DDT

DDT is an Eclipse-based IDE for the D programming language:

Home Page:http://ddt-ide.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduced eponymous template syntax bug

mleise opened this issue · comments

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;
}();

Even more simple:

immutable twoDigitsInBase(uint base) = { 123 , 1232 } ;

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.)

Fair enough 👍 .
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.