www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13448] New: Class specification misses template classes in

https://issues.dlang.org/show_bug.cgi?id=13448

          Issue ID: 13448
           Summary: Class specification misses template classes in base
                    classes list
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/class.html#ClassDeclaration
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: websites
          Assignee: nobody puremagic.com
          Reporter: s.trump gmail.com
            Blocks: 10233

(http://dlang.org/class.html#ClassDeclaration) says after ':' there is a list
of base classes. But "BaseClassList" rule allows only 'Identifier' separated
with comma. 'TemplateInstance' rule must be added.

Let's open sample code from http://dlang.org/template.html

 interface Addable(T)
 {
     final R add(this R)(T t)
     {
         return cast(R)this;  // cast is necessary, but safe
     }
 }
 
 class List(T) : Addable!T
 {
     List remove(T t)
     {
         return this;
     }
 }
 
 void main()
 {
     auto list = new List!int;
     list.add(1).remove(1);  // ok
 }
I want to pay attention at line 9:
 class List(T) : Addable!T
"Addable!T" doesn't fit rule 'BaseClassList'. This sample code is compiled by DMD2 compiler (but interface must be replaced with class previously). So I think specification must be updated in "SuperClass" and "Interface" rules.
 SuperClass:
    Identifier
    TemplateInstance

 Interface:
    Identifier
    TemplateInstance
--
Sep 09 2014