www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23589] New: [REG2.095] Purity check special case gives

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

          Issue ID: 23589
           Summary: [REG2.095] Purity check special case gives circular
                    reference error.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

The testcase below compiles with 2.094, but fails compilation with 2.095.
The regression is introduced by this PR:
https://github.com/dlang/dmd/pull/12023 (introduces size check for the special
case of zero-sized struct). Removing the size check
(`sd.determineSize(v.loc);`) "fixes" the regression.

Testcase:
```
struct TemplStr(string Description_) {}

template A() {
    bool member;
    alias THIS = typeof(this);
    static THIS staticInstance;
    static asSize()
    {
        return staticInstance.member;
    }
}

template B() {
    enum cols = columns();

    enum cols_two = cols;
    TemplStr!(cols_two) tstr;
}

struct S
{
  mixin A;
  mixin B;

  static string columns() {
    auto dummy = &asSize;
    return "as";
  }
}
```

--
Dec 28 2022