[Issue 23771] New: Array equals should be handled by CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 11 00:13:38 UTC 2023


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

          Issue ID: 23771
           Summary: Array equals should be handled by CTFE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

Array Equals gets lowered to __equals(), but CTFE should not rely on it.

This change to expressionsem.d demonstrates it:
---
  // lower some array comparisons to object.__equals(e1, e2)
  if (sc.needsCodegen() &&   <== add this test
      (needsArrayLowering || (t1.ty == Tarray && t2.ty == Tarray)))
  {
     //printf("Lowering to __equals %s %s\n", exp.e1.toChars(),
exp.e2.toChars());
---
resulting in:

fail_compilation/diag7420.d(22):  called from here: `__equals(y, "abc")`

--


More information about the Digitalmars-d-bugs mailing list