January 21, 2024
https://issues.dlang.org/show_bug.cgi?id=24350

          Issue ID: 24350
           Summary: Cannot access a member of an 'alias this' member
                    through an alias
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: maxsamukha@gmail.com

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).

--