www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23771] New: Array equals should be handled by CTFE

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 puremagic.com
          Reporter: bugzilla 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")`

--
Mar 10 2023