www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21540] New: Cannot pass associative array of function

https://issues.dlang.org/show_bug.cgi?id=21540

          Issue ID: 21540
           Summary: Cannot pass associative array of function pointers to
                    const AA parameter with lower attributes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

As an example, an associative array of  safe function pointers cannot be passed
to a function taking an associative array that has its value type the const
version of the corresponding  system function pointers.

    void f(const(void function())[string] aa) { }

    void main()
    {
        void function()  safe fp = { };
        void function()  safe[string] aa = [ "a": fp ];
        f(aa); // error
    }

For delegates instead of function pointers, the call to f compiles as it
should.

--
Jan 10