Reduced eponymous template syntax bug
mleise opened this issue · comments
Marco Leise commented
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
Even more simple:
immutable twoDigitsInBase(uint base) = { 123 , 1232 } ;
Marco Leise commented
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
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.