www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12905] New: [AA] `opCmp` in any struct allow other struct


          Issue ID: 12905
           Summary: [AA] `opCmp` in any struct allow other struct usage in
                    associative array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com

This code compiles but shouldn't:
struct T { int opCmp(); }

struct S {}
int[S] aa; // Compiles iff `T` with `opCmp` exists

Currently the compiler tries to enforce `opCmp` existence on AA keys so this is
accepts-invalid bug. Also there is Issue 12255 complaining about `opCmp`
requirement, but anyway this code must either compile or not without depending
on `T` existence.

IMO, this bug causes huge confusion in AAs and should be fixed ASAP.

Jun 13 2014