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


--- Comment #0 from Luís Marques <luis luismarques.eu> 2013-11-22 09:02:53 PST
---
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


--- Comment #1 from monarchdodra gmail.com 2013-11-22 13:47:32 PST ---
(In reply to comment #0)
 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



--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-11-22 22:16:30 PST ---
(In reply to comment #0)
 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


--- Comment #3 from yebblies <yebblies gmail.com> 2013-11-23 19:27:41 EST ---
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