December 01, 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() {}
    }
December 02, 2018
On Saturday, 1 December 2018 at 18:09:39 UTC, Neia Neutuladh wrote:
> 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() {}
>     }

Not sure if intentional or not, but usual you'd do it like this:


     struct A
     {
         @nogc:
         ...
         void foo() {}
     }