[Issue 17974] getSymbolsByUDA is returns unusable symbols when used in foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 8 19:41:49 UTC 2017


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

--- Comment #1 from Artem Borisovskiy <kolos80 at bk.ru> ---
What I meant to say is that it can't even access the symbol to test if it has
the attribute. Anyway, here's some more funny (not so at work) stuff:

// main.d
import std.traits;
enum Attr;

static struct FUBAR
{
    @Attr int a;
    void dummy()
    {
        static foreach (symbol; getSymbolsByUDA!(FUBAR, Attr))
            pragma(msg, getUDAs!(symbol, Attr).stringof);
    }
}

void main()
{
    static foreach (symbol; getSymbolsByUDA!(FUBAR, Attr))
        pragma(msg, getUDAs!(symbol, Attr).stringof);
}

Now I'm lost:

src/main.d(10): Error: value of 'this' is not known at compile time
()
(Attr)

But if I make `dummy' static, it works:
(Attr)
(Attr)

The loop works even on module level (as it should). So it doesn't work only in
non-static methods of FUBAR.

--


More information about the Digitalmars-d-bugs mailing list