www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10381] New: Nonsense associative array comparison

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381

           Summary: Nonsense associative array comparison
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com



18:29:05 MSD ---
Currently associative arrays are compared by comparing its `impl` pointers e.g.
`aa1 < aa2` is rewritten as `cast(void*) aa1 > cast(void*) aa2` instead of
calling a runtime function.

---
void main()
{
    int[int] aa1 = [0: 1];
    int[int] aa2 = [0: 1];
    assert(aa1 == aa2); // Passes
    assert(!(aa1 < aa2) && !(aa1 > aa2)); // Fails, different `impl`-s
}
---

And yes, there is not such function in druntime so this is druntime's issue
too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381




IMO, comparing AA's with < should be a compile-time error. AA's are unordered
so it makes no sense to use < to compare them.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc




 IMO, comparing AA's with < should be a compile-time error. AA's are unordered
 so it makes no sense to use < to compare them.
There are some meaningful (and occasionally useful) operations done on whole associative arrays, like testing if the keys of an associative array are a subset (or strict subset) of the keys of another associative array. But probably it's not the best idea to use < to perform similar set comparisons... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 08 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381




https://github.com/D-Programming-Language/dmd/pull/2575

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code dawg.eu




 There are some meaningful (and occasionally useful) operations done on whole
 associative arrays, like testing if the keys of an associative array are a
 subset (or strict subset) of the keys of another associative array.
Yes, interesting but too complex/specialized for built-in functionality IMHO. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381






 There are some meaningful (and occasionally useful) operations done on whole
 associative arrays, like testing if the keys of an associative array are a
 subset (or strict subset) of the keys of another associative array.
Yes, interesting but too complex/specialized for built-in functionality IMHO.
FWIW, using == on AA's already does (a superset of) what an AA subset operation would do (iterate over AA keys and check for existence in the other AA). But I agree that it shouldn't be built-in functionality. Maybe a nice library wrapper in std.array, but not much beyond that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f357fb07cfbb5b64c5a4ccc12a4ce7b83cb7a3b8
Fix issue 10381 Nonsense associative array comparison

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10381


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2013