www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11582] New: inherit element/slice of type tuple

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

           Summary: inherit element/slice of type tuple
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: luis luismarques.eu



---
This gives an error:

    class C(E...) : E[0] 
    {
    }

Error: members expected
Error: { } expected following aggregate declaration

Inheriting from all the types in the type tuple is OK:

    class C(E...) : E
    {
    }

Workaround:

    template C(E...)
    {
        alias T = E[1..$];

        class C : T
        {
        }
    }

This seems somewhat similar to Issue 11581

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 22 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11582


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com




 This gives an error:
 
     class C(E...) : E[0] 
     {
     }
 
 Error: members expected
 Error: { } expected following aggregate declaration

 ...

 Workaround:
Another one, which might be "cleaner" depending on how you are actually using E: //---- class C(Base, E...) : Base {} //---- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11582





 This gives an error:
 
     class C(E...) : E[0] 
     {
     }
 
 Error: members expected
 Error: { } expected following aggregate declaration
This is syntactic issue. Currently class declaration grammar is defined as follows: ---- ClassDeclaration: class Identifier BaseClassListopt ClassBody ClassTemplateDeclaration BaseClassList: : SuperClass : SuperClass , Interfaces : Interfaces SuperClass: Identifier ---- SuperClass should be Identifier, so it does not accept E[0]. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 22 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11582


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Actually, parseBaseClasses uses parseBasicType.  This was to include things
like typeof.

class A {}
A a;
class B : typeof(a) {}

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