www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12527] New: Cannot make system function/delegate alias in a safe section

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12527

           Summary: Cannot make  system function/delegate alias in a  safe
                    section
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla kyllingen.net



07:25:09 PDT ---
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)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12527




11:55:52 PDT ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2014