[Issue 21540] New: Cannot pass associative array of function pointers to const AA parameter with lower attributes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 11 01:18:39 UTC 2021


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 at puremagic.com
          Reporter: qs.il.paperinik at 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.

--


More information about the Digitalmars-d-bugs mailing list