Inconsistent attribute propagation?

Neia Neutuladh neia at ikeran.org
Sat Dec 1 18:09:39 UTC 2018


I noticed inconsistency with how builtin attributes propagate into types.

The following propagate to member functions:
* @safe
* const
* shared
* immutable
* linkage

The following do not:
* pure
* @nogc
* nothrow

Is this intentional? I'm not seeing anything in the spec about it.

Test code:

    import std.stdio;
    void main()
    {
        writeln(__traits(getFunctionAttributes, A.foo).stringof);
        writeln(__traits(getLinkage, A.foo));
    }
    
    @safe @nogc pure const shared nothrow extern(C)
    struct A
    {
        void foo() {}
    }


More information about the Digitalmars-d mailing list