www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11591] New: `const`/`immutable` `std.typecons.Tuple`-s with classes fails at runtime as associative array keys

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

           Summary: `const`/`immutable` `std.typecons.Tuple`-s with
                    classes fails at runtime as associative array keys
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-11-24
12:46:59 MSK ---
At least a year ago `const`/`immutable` `std.typecons.Tuple`-s with classes
worked as associative array keys. The fact it fails at runtime now is rather
nasty. It should either work or fail to compile.

---
import std.typecons;

void main()
{
    alias T = Tuple!Object;
    int[const T] aa; // No CT errors
    aa[T()] = 1;
    aa[T()] = 1; // Error at runtime
}
---
object.Error: TypeInfo.compare is not implemented
---

E.g. fixing Issue 11590 will fix this issue by rejecting such associative
arrays to compile unless Issue 1824 is fixed.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 24 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|`const`/`immutable`         |`std.typecons.Tuple`-s with
                   |`std.typecons.Tuple`-s with |classes fails at runtime as
                   |classes fails at runtime as |associative array keys
                   |associative array keys      |


--- Comment #1 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-11-24
13:33:08 MSK ---
Sorry, original comment is wrong. The regression is for unqualified tuples:
---
import std.typecons;

void main()
{
    alias T = Tuple!Object;
    int[T] aa; // No CT errors
    aa[T()] = 1;
    aa[T()] = 1; // Error at runtime
}
---

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2013-12-31
14:22:05 PST ---
This comes about because std.typecons.Tuple generates a struct but does not
generate an opCmp operator overload function for it. Actually, it does build an
opCmp, but as a template, whereas in clone.c buildXopCmp() looks for a function
named opCmp, not a template.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #3 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2014-01-01
02:53:25 MSK ---
(In reply to comment #2)
 This comes about because std.typecons.Tuple generates a struct but does not
 generate an opCmp operator overload function for it. Actually, it does build an
 opCmp, but as a template, whereas in clone.c buildXopCmp() looks for a function
 named opCmp, not a template.

Actually there is no problem with the fact it's a template here IIRC. The problem is the template (a `const` overload) can't be instantiated. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2013-12-31
18:53:04 PST ---
I did some more digging on this. The fundamental problem is that for AA's to
work, then opCmp() has to work. opCmp needs an ordering, a "<" operation. But
there is no defined ordering for Object.

Hence, it fails.

I don't see how const makes any difference. Nor is this really about Tuples,
it's about using Object as a key for an associative array.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2013-12-31
21:20:55 PST ---
https://github.com/D-Programming-Language/dmd/pull/3054

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2014-01-01
02:46:09 PST ---
*** Issue 11590 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 01 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #7 from github-bugzilla puremagic.com 2014-01-02 10:31:28 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/0e08634edb3f06c3879f679ca97e7dde5340b915
fix Issue 11591 - std.typecons.Tuple -s with classes fails at runtime as
associative array keys

https://github.com/D-Programming-Language/dmd/commit/10de92b5bbfda4850cb7f17885d7d9a2c7ad0290
Merge pull request #3054 from WalterBright/fix11591

Regression fix Issue 11591 - std.typecons.Tuple -s with classes fails at
runtime as associative array keys

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11591



--- Comment #8 from github-bugzilla puremagic.com 2014-01-07 02:32:43 PST ---
Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ac329ecd01fb9a24d1ec9d60f2d26fe2a14f8e62
Merge pull request #3054 from WalterBright/fix11591

Regression fix Issue 11591 - std.typecons.Tuple -s with classes fails at
runtime as associative array keys

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2014