Thread overview
[Issue 539] New: can't instantiate nested template of same name
Nov 17, 2006
d-bugmail
Nov 19, 2006
d-bugmail
Sep 10, 2007
d-bugmail
November 17, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=539

           Summary: can't instantiate nested template of same name
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: lovesyao@hotmail.com


template test(T){
  T test(T i)(){
    return i;
  }
}

int test2(int i)(){
  return i;
}

template test3(T){
  alias int dummy;
  T test3(T i)(){
    return i;
  }
}

void main(){
  assert(test2!(10)()==10);//ok

  assert(test3!(int).test3!(10)()==10);//ok

  assert(test!(int).test!(10)()==10);//compile error
  assert(test!(int)!(10)()==10);//syntax error
}


-- 

November 19, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=539





------- Comment #1 from lovesyao@hotmail.com  2006-11-18 23:19 -------
I think that more short syntax is needed for nested templates.
template Test(T)(T t){}
class Test(T)(T t){}
void Test(T)(T t)(){}
So I want that fix like test!(int)!(10)().


-- 

September 10, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=539


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Keywords|                            |rejects-valid




------- Comment #2 from smjg@iname.com  2007-09-09 20:33 -------
By my analysis:

- the line commented "compile error" should not compile - because test!(int) evaluates not to the template instance itself, but to the template function therein.

- the line commented "syntax error" should compile and pass the assert.

And BTW, please report compiler messages in full.


-- 

November 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=539


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei@metalanguage.com
         Resolution|                            |INVALID


--- Comment #3 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-11-26 11:54:27 PST ---
This is by design. There is no way to avoid the eponymous rewrite.

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