www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22619] New: [REG2.098.1] Nullable regression introduced by

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

          Issue ID: 22619
           Summary: [REG2.098.1] Nullable regression introduced by new
                    copy ctor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

This newly fails to compile with DMD v2.098.1, but works with 2.098.0:
```
import std.typecons : Nullable, nullable;

struct Module {
    Nullable!string name;
}

Nullable!(const(Module)) findModule(const ref Module mod) {
    return nullable(mod);
}
```

Error:
```
std/typecons.d(3100): Error: variable
`std.typecons.nullable!(const(Module)).nullable.__copytmp15` `inout` variables
can only be declared inside `inout` functions
bug.d(8): Error: template instance `std.typecons.nullable!(const(Module))`
error instantiating
```

The copy ctor was added in https://github.com/dlang/phobos/pull/8318.

--
Dec 21 2021