D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2904 - (D1 only) template instantiation of non template allowed
Summary: (D1 only) template instantiation of non template allowed
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2009-04-27 06:02 UTC by Tomas Lindquist Olsen
Modified: 2019-08-10 13:55 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Tomas Lindquist Olsen 2009-04-27 06:02:01 UTC
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.
Comment 1 Trass3r 2011-09-05 04:42:33 UTC
Seems like this one has been fixed in the meantime.

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