Bug 5783 – Const Tuple equality

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-03-24T16:55:00Z
Last change time
2013-02-03T13:08:22Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Blocks
7586

Comments

Comment #0 by bearophile_hugs — 2011-03-24T16:55:26Z
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; }
Comment #1 by kennytm — 2011-03-24T17:28:55Z
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.
Comment #2 by bearophile_hugs — 2011-03-24T17:31:21Z
(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?
Comment #3 by bearophile_hugs — 2012-02-26T14:52:17Z
*** Issue 7586 has been marked as a duplicate of this issue. ***
Comment #4 by andrej.mitrovich — 2013-02-03T13:08:22Z
Seems to be fixed in 2.061.