www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2904] New: template instantiation of non template allowed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2904

           Summary: template instantiation of non template allowed
           Product: D
           Version: 1.043
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


DMD accepts the following code:

bar.d:
=========
class A {
        void method(char[] f) {}
}
static this() {
        (new A).method!()("foo");
        //(new A).method("foo");
}
=========

$ dmd bar.d -c
$ nm bar.o | grep method
00000000 T _D3bar12_staticCtor1FZv6methodMFAaZv
$

If valid syntax is used the symbol is correct:

bar.d:
=========
class A {
        void method(char[] f) {}
}
static this() {
        //(new A).method!()("foo");
        (new A).method("foo");
}
=========

$ dmd bar.d -c
$ nm bar.o | grep method
00000000 T _D3bar1A6methodMFAaZv
$

I got this from LDC ticket: http://dsource.org/projects/ldc/ticket/261
So apparently people are using this for something :/ The AST seems somewhat
broken, so making it work none-the-less (which of course we shouldn't) in LDC
seems a bit problematic.


-- 
Apr 27 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2904


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de
           Platform|x86                         |All



Seems like this one has been fixed in the meantime.

dmd 2.055 gives:
Error: (new A).method isn't a template

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