Bug 17870 – Can't alias a mix of parent and child class members

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-10-01T19:03:30Z
Last change time
2021-12-04T10:08:10Z
Keywords
pull
Assigned to
No Owner
Creator
bitwise

Comments

Comment #0 by nicolas.jinchereau — 2017-10-01T19:03:30Z
class B { int a; } class D1 : B { int b; } class D2 : D1 { int c; } template TupleOf(Classes...) { static if(Classes.length > 1) alias TupleOf = AliasSeq!(Classes[0].tupleof, TupleOf!(Classes[1..$])); else static if(Classes.length == 1) alias TupleOf = AliasSeq!(Classes[0].tupleof); else alias TupleOf = AliasSeq!(); } int main(string[] argv) { alias allClasses = AliasSeq!(D2, BaseClassesTuple!D2); alias allFields = TupleOf!allClasses; return 0; } Error: template instance AliasSeq!(b, a) AliasSeq!(b, a) is nested in both D1 and B Error: template instance main.TupleOf!(D1, B, Object) error instantiating instantiated from here: TupleOf!(D2, D1, B, Object)
Comment #1 by boris2.9 — 2020-08-27T22:20:22Z
*** Issue 17233 has been marked as a duplicate of this issue. ***
Comment #2 by boris2.9 — 2020-08-27T22:25:56Z
int main(string[] argv) { alias allClasses = AliasSeq!(D2, BaseClassesTuple!D2); alias allFields = TupleOf!allClasses; pragma(msg, allClasses); pragma(msg, allFields.stringof); return 0; } Output should be: (D2, D1, B, Object) tuple(c, b, a) Reduced test case: alias AliasSeq(T...) = T; class A { int a = 1; } class B : A { int b = 2; alias tup = AliasSeq!(b, a); } void main() { static const ins = new B; static assert(&ins.tup[0] == &ins.b); static assert(&ins.tup[1] == &ins.a); static assert(ins.tup == AliasSeq!(2,1)); }
Comment #3 by dlang-bot — 2020-08-27T22:40:40Z
@BorisCarvajal created dlang/dmd pull request #11633 "Fix Issue 17870 - Can't alias a mix of parent and child class members" fixing this issue: - Fix Issue 17870 - Can't alias a mix of parent and child class members https://github.com/dlang/dmd/pull/11633
Comment #4 by dlang-bot — 2021-12-03T16:26:12Z
@12345swordy created dlang/dmd pull request #13380 "Fix Issue 17870 - Can't alias a mix of parent and child class members" fixing this issue: - Fix Issue 17870 - Can't alias a mix of parent and child class members https://github.com/dlang/dmd/pull/13380
Comment #5 by dlang-bot — 2021-12-04T10:08:10Z
dlang/dmd pull request #13380 "Fix Issue 17870 - Can't alias a mix of parent and child class members" was merged into master: - 7e0130e8c52fb12a2dc780edd43c2b177ff79da6 by 12345swordy: Fix Issue 17870 - Can't alias a mix of parent and child class members https://github.com/dlang/dmd/pull/13380