www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22420] New: [REG2.098] Apparent CTFE regression

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

          Issue ID: 22420
           Summary: [REG2.098] Apparent CTFE regression
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

Caused or at least triggered by https://github.com/dlang/dmd/pull/13137.
Reduced by Iain (thanks a lot!):

```
struct File
{
    ~this()
    {
    }
    File impl()
    {
        return File.init;
    }
    alias impl this;
}
struct Variable
{
    this(File)(File) { }
    this(File)(File[]) { }
}
Variable wrapFunctionReturn(alias handler)(Variable params)
{
    return Variable(handler(params));
}
void registerFile()
{
    wrapFunctionReturn!((Variable) {
            return File.init;
    })(Variable.init);
}
```

Compiles fine with DMD v2.097.2; v2.098.0 and current stable fail with:

bla.d(19): Error: variable `params` cannot be read at compile time
bla.d(19):        called from here: `__lambda1(params)`
bla.d(23): Error: template instance
`current.registerFile.wrapFunctionReturn!((Variable)
{
return File.init;
}
)` error instantiating

--
Oct 18 2021