Thread overview
[Issue 5783] New: Const Tuple equality
Mar 25, 2011
kennytm@gmail.com
Feb 03, 2013
Andrej Mitrovic
March 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5783

           Summary: Const Tuple equality
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2011-03-24 16:55:26 PDT ---
Problem found on tuples by Magnus Lie Hetland, then reduced:


import std.typecons;
void main() {
    alias Tuple!int T;
    const T t;
    bool b = t == t;
}


DMD 2.052 shows:

test.d(5): Error: template std.typecons.Tuple!(int).Tuple.opEquals(R) if
(isTuple!(R)) does not match any function template declaration
test.d(5): Error: template std.typecons.Tuple!(int).Tuple.opEquals(R) if
(isTuple!(R)) cannot deduce template function from argument types
!()(const(Tuple!(int)))



I think it can be further reduced to:

struct Foo(T) {
    bool opEquals(R)(R rhs) {
        return false;
    }
}
void main() {
    const Foo!int f;
    bool result = f == f;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5783


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm@gmail.com


--- Comment #1 from kennytm@gmail.com 2011-03-24 17:28:55 PDT ---
opEquals is a non-const method (issue 1824). Of course a const object cannot call it. The reduced test case is working as expected. The problem is just Tuple needs a const opEquals.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5783



--- Comment #2 from bearophile_hugs@eml.cc 2011-03-24 17:31:21 PDT ---
(In reply to comment #1)
> opEquals is a non-const method (issue 1824). Of course a const object cannot call it. The reduced test case is working as expected. The problem is just Tuple needs a const opEquals.

Thank you for your answer.

A secondary problem here is that I wasn't unable to understand what the problem was from those error messages. So is it possible to improve them?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5783



--- Comment #3 from bearophile_hugs@eml.cc 2012-02-26 14:52:17 PST ---
*** Issue 7586 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5783


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |WORKSFORME


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-03 13:08:22 PST ---
Seems to be fixed in 2.061.

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