www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 540] New: Nested template member function error - "function expected before ()"

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

           Summary: Nested template member function error - "function
                    expected before ()"
           Product: D
           Version: 0.174
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: wbaxter gmail.com


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)'


-- 
Nov 17 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540


kamm incasoftware.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kamm incasoftware.de




------- Comment #1 from kamm incasoftware.de  2007-04-24 03:18 -------
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)'


-- 
Apr 24 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540





------- Comment #2 from clayasaurus gmail.com  2007-06-20 10:38 -------
This issue is a show stopper for the Arc v.2 release, unless we find a
workaround of some sort. 


-- 
Jun 20 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540





------- Comment #3 from oskar.linde gmail.com  2007-06-21 06:02 -------
Created an attachment (id=148)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=148&action=view)
patch to DMD 0.175


-- 
Jun 21 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540





------- Comment #4 from oskar.linde gmail.com  2007-06-21 06:03 -------
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.


-- 
Jun 21 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540


clayasaurus gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |blocker




-- 
Jun 26 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #5 from bugzilla digitalmars.com  2007-07-01 13:25 -------
Fixed DMD 1.018 and DMD 2.002


-- 
Jul 01 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=540





------- Comment #6 from thomas-dloop kuehne.cn  2007-07-23 14:55 -------
Added to DStress as
http://dstress.kuehne.cn/run/t/template_64_A.d
http://dstress.kuehne.cn/run/t/template_64_B.d
http://dstress.kuehne.cn/run/t/template_64_C.d


-- 
Jul 23 2007