www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5783] New: Const Tuple equality

reply d-bugmail puremagic.com writes:
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



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: -------
Mar 24 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5783


kennytm gmail.com changed:

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



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: -------
Mar 24 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5783





 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: -------
Mar 24 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5783




*** 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: -------
Feb 26 2012
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 03 2013