Bug 11582 – inherit element/slice of type tuple

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-22T09:02:00Z
Last change time
2015-08-10T15:48:34Z
Assigned to
nobody
Creator
luis

Comments

Comment #0 by luis — 2013-11-22T09:02:53Z
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
Comment #1 by monarchdodra — 2013-11-22T13:47:32Z
(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 {} //----
Comment #2 by k.hara.pg — 2013-11-22T22:16:30Z
(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].
Comment #3 by yebblies — 2013-11-23T00:27:41Z
Actually, parseBaseClasses uses parseBasicType. This was to include things like typeof. class A {} A a; class B : typeof(a) {}
Comment #4 by luis — 2015-08-10T15:48:34Z