www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 539] New: can't instantiate nested template of same name

reply d-bugmail puremagic.com writes:
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
}


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






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)().


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


smjg iname.com changed:

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





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.


-- 
Sep 09 2007
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Nov 26 2010