Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Reduced eponymous template syntax bug #135

Closed
mleise opened this issue Apr 21, 2016 · 3 comments
Closed

Reduced eponymous template syntax bug #135

mleise opened this issue Apr 21, 2016 · 3 comments

Comments

@mleise
Copy link

mleise commented Apr 21, 2016

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
Copy link
Contributor

Even more simple:

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

@mleise
Copy link
Author

mleise commented May 12, 2016

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
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants