[Issue 22159] New: "==" causeses error for array of classes in safe method

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 30 12:03:20 UTC 2021


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

          Issue ID: 22159
           Summary: "==" causeses error for array of classes in safe
                    method
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: lucidanescu28 at yahoo.com

The following code compiles:

class C { int a; this(int) @safe {} }

void main()
{
    C c = new C(1);
    C[] a = [c, c, c];
    assert(a == [c, c, c]);
}

The following code fails:

class C { int a; this(int) @safe {} }

@safe void main()
{
    C c = new C(1);
    C[] a = [c, c, c];
    assert(a == [c, c, c]);
}

with the message: incompatible types for array comparison: `C[]` and `C[3]`

--


More information about the Digitalmars-d-bugs mailing list