[Issue 16321] ICE with delegate in UDA

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 29 14:56:50 UTC 2022


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

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |dkorpel at live.nl

--- Comment #2 from Dennis <dkorpel at live.nl> ---
Reduced a bit:
```
struct NameAttribute
{
    int delegate() foo;
}

static NameAttribute getNamedAttribute(alias S)()
{
    return __traits(getAttributes, S)[0];
}

struct MyStruct
{
    @NameAttribute({ return 42; }) int a;
}

void main()
{
    MyStruct m;
    enum nameAttr = getNamedAttribute!(m.a);
}
```

If you remove `static`, you get:
```
Error: need `this` for `getNamedAttribute` of type `pure nothrow @nogc @safe
NameAttribute()`
```

--


More information about the Digitalmars-d-bugs mailing list