www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12529] New: Function/delegate type alias picks up safe attribute from surrounding scope

https://d.puremagic.com/issues/show_bug.cgi?id=12529

           Summary: Function/delegate type alias picks up  safe attribute
                    from surrounding scope
           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


--- Comment #0 from Lars T. Kyllingstad <bugzilla kyllingen.net> 2014-04-06
11:48:27 PDT ---
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())

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