www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23519] New: Unnecessary and inconsistent restrictions on

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

          Issue ID: 23519
           Summary: Unnecessary and inconsistent restrictions on delegate
                    subtyping
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timon.gehr gmx.ch

DMD v2.101.0:

class Super{}
class Sub: Super{}

void main(){
    void delegate(Super) a0;
    void delegate(Sub) b0=a0; // error

    const(void delegate(Super))[] a1;
    const(void delegate(Sub))[] b1=a1; // ok

    Sub delegate() a2;
    Super delegate() b2=a2; // ok

    const(Sub delegate())[] a3;
    const(Super delegate())[] b3=a3; // error
}

All of those should work.

--
Nov 29 2022