[Issue 23105] `__trait(getMember)` and `mixin()` of the same code as a string behave differently

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 12 14:20:42 UTC 2022


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

--- Comment #2 from Basile-z <b2.temp at gmx.com> ---
somewhat better. Static evaluation is known to have problems with shortcut &&
and ||:

```
module self;

enum getMember = `__traits(getMember, sym, m)`;

template test(alias sym)
{
    static foreach (m; __traits(allMembers, sym))
    {
        static if (m == "object")
            static if (is(__traits(getMember, sym, "object")==module))
                static assert(0);      // pass
        static if (m == "object")
            static if (is(mixin(getMember)==module))
                static assert(0, m);   // fails
    }
}

void main()
{
    alias _ = test!(self);
}     
```

--


More information about the Digitalmars-d-bugs mailing list