Bug 540 – Nested template member function error - "function expected before ()"

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-11-17T07:37:00Z
Last change time
2014-02-15T13:20:11Z
Keywords
patch, rejects-valid
Assigned to
bugzilla
Creator
wbaxter

Attachments

IDFilenameSummaryContent-TypeSize
148dmd-nestmemifti.patchpatch to DMD 0.175text/plain870

Comments

Comment #0 by wbaxter — 2006-11-17T07:37:25Z
A template member function with nesting confuses the compiler. It is fine with the equivalent construct existing outside a class. It only breaks when you put it inside the class. class Foo { template myCast(T) { T myCast(U)(U val) { return cast(T) val; } } } void main() { Foo foo = new Foo; int i = foo.myCast!(int)(1.0); } --> Error: function expected before (), not 'foo dotexp template myCast(U)'
Comment #1 by kamm-removethis — 2007-04-24T03:18:20Z
You can also easily trigger this IFTI problem with named template mixins: template A() { static void foo(T)(T t) {} } struct Bar { mixin A!() a; } void main() { A!().foo(1); // works Bar.a.foo!(int)(1); // works Bar.a.foo(1); // error } Error: function expected before (), not 'Bar dotexp template foo(T)'
Comment #2 by clayasaurus — 2007-06-20T10:38:53Z
This issue is a show stopper for the Arc v.2 release, unless we find a workaround of some sort.
Comment #3 by oskar.linde — 2007-06-21T06:02:09Z
Created attachment 148 patch to DMD 0.175
Comment #4 by oskar.linde — 2007-06-21T06:03:05Z
Here is a patch to DMD 0.175 that fixes this issue (posted december 1st to the announce newsgroup). It is not really well tested, but illustrates that the required change is quite small.
Comment #5 by bugzilla — 2007-07-01T13:25:47Z
Fixed DMD 1.018 and DMD 2.002
Comment #6 by thomas-dloop — 2007-07-23T14:55:25Z