Consider:
@safe:
alias F = void function();
This wrongly makes F an alias of "void function() @safe" rather than "void function()".
Here is a test case which should compile, but which fails to do so:
void foo() { }
@safe:
alias F = void function();
@trusted void bar(F f) { f(); }
void main() { bar(&foo); }
DMD says:
bug.d(6): Error: function bug.bar (void function() @safe f) is not callable using argument types (void function())
Comment #1 by andrej.mitrovich — 2014-05-17T12:56:45Z
But this /is/ consistent with how extern(C) works. I think we should apply all attributes consistently, whatever the final decision is.
This is a behavior change, not a bug. Marked as enhancement.
Comment #4 by bugzilla — 2014-06-04T21:20:51Z
I think it *is* a bug. To me, the statement clearly says "make F an alias for void function()". Attributes should only apply to the declared symbol itself (and an alias obviously cannot be @safe; only functions can).
Consider this:
const:
alias T = int;
Should T now be an alias for int or const(int)? Currently, it is the former, as I think it should be.
Comment #5 by bugzilla — 2016-06-14T23:14:30Z
This is operating correctly. An alias should not be able to override the safety of the type, as in https://issues.dlang.org/show_bug.cgi?id=12527, but if it is the default it should be settable.