www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22618] New: [REG2.078] Rejects valid depending on ordering of

https://issues.dlang.org/show_bug.cgi?id=22618

          Issue ID: 22618
           Summary: [REG2.078] Rejects valid depending on ordering of
                    alias this and other alias
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

Testcase:
```
struct BaseBlock
{
    void baseFoo()
    {
    }
}

template someMixin(alias Func)
{
}

struct BlockHandle(T)
{
    T* block;

    void foo()
    {
        block.baseFoo;
    }

    mixin someMixin!((BlockHandle!T self) {
        self.foo;
    });
}

struct ChildBlock
{
    version (BUG)
    {
        alias Handle = BlockHandle!(typeof(this));

        BaseBlock base;
        alias base this;
    }
    else
    {
        BaseBlock base;
        alias base this;

        alias Handle = BlockHandle!(typeof(this));
    }
}
```

Compilation without any flags succeeds.
But compilation with -version=BUG resuls in the error:
  aliasbug.d(18): Error: no property `baseFoo` for type `aliasbug.ChildBlock*

Apparently the `alias this` is ignored during the evaluation of `alias Handle =
BlockHandle!(typeof(this));`, if the `alias this` is defined after the `alias
Handle = ...`.

The testcase succeeds with/without -version=BUG for dlang 2.077. (The bug was
detected as a regression between 2.093 and 2.097, but after dustmiting to the
testcase above it fails also with 2.093.)

--
Dec 21 2021