Bug 5101 – Poorly formed error against non-const template on const object

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-10-22T09:18:00Z
Last change time
2013-01-23T17:26:13Z
Keywords
diagnostic
Assigned to
nobody
Creator
Jesse.K.Phillips+D

Comments

Comment #0 by Jesse.K.Phillips+D — 2010-10-22T09:18:10Z
The program below fails to compile because the MyClass.get template method is not const. But this report is on the error message returned: .\templateconst.d(10): Error: function std.variant.VariantN!(maxSize).VariantN.g et!(double).get () is not callable using argument types () I would expect it to complain that the call was not to a const method on a const object. void main() { MyClass a; test(a); } void test(const MyClass c) { auto b = c.get!double; } class MyClass { real pi = 3.14; T get(T)() { return cast(T) pi; } }
Comment #1 by bearophile_hugs — 2010-10-22T10:11:41Z
See also bug 4947
Comment #2 by andrej.mitrovich — 2013-01-23T17:25:36Z
Add parens to the call and you'll get this in 2.061: test.d(7): Error: mutable method test.MyClass.get!(double).get is not callable using a const object *** This issue has been marked as a duplicate of issue 4947 ***
Comment #3 by andrej.mitrovich — 2013-01-23T17:26:13Z
(In reply to comment #2) > Add parens to the call and you'll get this in 2.061: Sorry, I meant 2.062 git-head.