Bug 24350 – Cannot access a member of an 'alias this' member through an alias

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2024-01-21T08:12:46Z
Last change time
2024-12-13T19:32:42Z
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#20386 →

Comments

Comment #0 by maxsamukha — 2024-01-21T08:12:46Z
Some people don't consider this a bug, but I do, hence the report. struct S { int x; } struct S2 { S s; alias this = s; alias x = S.x; } auto x = S2().x; // fail One of the practical consequences of this, which effected my work, is the impossibility to overload functions in a way consistent with other cases of name importing. Compare: 1) class A { void foo() {} } class B: A { alias foo = A.foo; void foo(int) {} } void main() { (new B).foo(); // pass } 2) template A() { void foo() {} } struct B { mixin A a; alias foo = a.foo; void foo(int) {} } void main() { B().foo(); // pass } 3) struct A { void foo() {} } struct B { A a; alias this = a; alias foo = A.foo; void foo(int) {} } void main() { B().foo(); // fail } While some people put 1) and 3) in different categories, I don't see a good reason for that - B in 3) is implicitly convertible to A, similar to 1).
Comment #1 by robert.schadek — 2024-12-13T19:32:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20386 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB