Thread overview
[Issue 5101] New: Poorly formed error against non-const template on const object
Oct 22, 2010
Jesse Phillips
Jan 24, 2013
Andrej Mitrovic
Jan 24, 2013
Andrej Mitrovic
October 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5101

           Summary: Poorly formed error against non-const template on
                    const object
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: Jesse.K.Phillips+D@gmail.com
                CC: Jesse.K.Phillips+D@gmail.com


--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> 2010-10-22 09:18:10 PDT ---
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;
   }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5101


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2010-10-22 10:11:41 PDT ---
See also bug 4947

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


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

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


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-23 17:25:36 PST ---
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 ***

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



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-23 17:26:13 PST ---
(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.

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