bug in compiles?

Steven Schveighoffer schveiguy at gmail.com
Fri Apr 12 13:36:03 UTC 2019


On 4/12/19 5:43 AM, Jacob Carlborg wrote:

> The problem is that "__traits(getAttributes, T)" in it self is not valid 
> code. It needs to be part of larger expression or statement.

It does work, as long as it's not an alias passed into a template:

void main()
{
    @(3) int a;
    static assert(__traits(compiles, __traits(getAttributes, a))); // OK
    alias b = a;
    static assert(__traits(compiles, __traits(getAttributes, b))); // OK
    static void foo(alias c)() {
       static assert(__traits(compiles, __traits(getAttributes, c))); // 
Error
    }
    foo!a();
}

It seems like a straight-up bug to me. I don't see the difference 
between those 3 calls.

-Steve


More information about the Digitalmars-d-learn mailing list