Bug 12527 – Cannot make @system function/delegate alias in a @safe section

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-06T07:25:00Z
Last change time
2016-10-01T11:47:46Z
Keywords
rejects-valid, safe
Assigned to
nobody
Creator
bugzilla
See also
https://issues.dlang.org/show_bug.cgi?id=15142, https://issues.dlang.org/show_bug.cgi?id=12529

Comments

Comment #0 by bugzilla — 2014-04-06T07:25:09Z
Consider the following: @safe: alias Fun = void function() @system; pragma (msg, Fun.stringof); alias Del = void delegate() @system; pragma (msg, Del.stringof); When compiling this, DMD prints: void function() @safe void delegate() @safe In other words, the @safe: directive somehow prevents the @system attribute from becoming part of the alias. Here is a test case which should compile, but which doesn't: @safe: alias Fun = void function() @system; @system void foo() { } @trusted void bar(Fun fun) { fun(); } void main() { bar(&foo); } This fails with the following error message: bug.d(5): Error: function bug.bar (void function() @safe fun) is not callable using argument types (void function() @system)
Comment #1 by bugzilla — 2014-04-06T11:55:52Z
Actually, I think the test case should compile even without the explicit @system attribute. I've filed a separate report about this, see issue 12529.
Comment #2 by bugzilla — 2016-06-14T22:51:52Z
Comment #3 by github-bugzilla — 2016-06-17T00:00:42Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b33039ba827142547bf9107007154abea54c9c23 fix Issue 12527 - Cannot make @system function/delegate alias in a @safe section https://github.com/dlang/dmd/commit/b67694a0d74437d3a1581da2b9f1b785dc7b3c88 Merge pull request #5867 from WalterBright/fix12527 fix Issue 12527 - Cannot make @system function/delegate alias in a @s…
Comment #4 by github-bugzilla — 2016-10-01T11:47:46Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b33039ba827142547bf9107007154abea54c9c23 fix Issue 12527 - Cannot make @system function/delegate alias in a @safe section https://github.com/dlang/dmd/commit/b67694a0d74437d3a1581da2b9f1b785dc7b3c88 Merge pull request #5867 from WalterBright/fix12527