[Issue 20686] failed static assert when using a combination of __traits in an unfinished type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 4 14:13:36 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20686

--- Comment #6 from Basile-z <b2.temp at gmx.com> ---
reduced to make reasoning on the problem easier

---
alias AliasSeq(TList...) = TList;

struct El(T) {
    void f2()       { f(null); }
    void f(T2)(T2)  { static assert(getSymbols!(El!T, "f2").length); }
}

alias X = El!char;

void main() {
    X().f('a');
}

template getSymbols(alias symbol, names...) {
    static if (names.length == 0)
        alias getSymbols = AliasSeq!();
    else
        alias getSymbols = 
          AliasSeq!(__traits(getMember, symbol, names[0]),
                             getSymbols!(symbol, names[1 .. $]));
}
---

observations:

1. if you move the X definition in main() then that compiles ;
2. if you use this insted of El!T in El.f() then this compiles ;
3. if you use f('0') in El.f2() then this compiles, 
   because this matches to the instance called in main() ;

The 3rd point seems meaningful.

--


More information about the Digitalmars-d-bugs mailing list