Summary: Implicit function pointer cast
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-03-18 05:56:43 PDT ---
void foo1(void function(int) f) {}
void foo2(void function(in int) f) {}
void bar1(int) {}
void bar2(in int) {}
void main() {
    foo1(&bar1); // OK
    foo2(&bar2); // OK
    foo1(&bar2); // Err
    foo2(&bar1); // Err

DMD 2.059head gives:

test.d(8): Error: function test.foo1 (void function(int) f) is not callable
using argument types (void function(const(int)))
test.d(8): Error: cannot implicitly convert expression (& bar2) of type void
function(const(int)) to void function(int)
test.d(9): Error: function test.foo2 (void function(const(int)) f) is not
callable using argument types (void function(int))
test.d(9): Error: cannot implicitly convert expression (& bar1) of type void
function(int) to void function(const(int))

I think void function(in int) is a subset of void function(int). So I think
only one of the calls should to give an error, while the other seems better as
safe implicit cast.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to