[Issue 22619] [REG2.098.1] Nullable regression introduced by new copy ctor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 6 13:57:41 UTC 2022


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

Robert Schadek <robertschadek at posteo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robertschadek at posteo.de

--- Comment #1 from Robert Schadek <robertschadek at posteo.de> ---
In 2.098.1 I get the following as well.

```dlang
Nullable!(T) mapHelper(T)(T[] data, long id) {
    auto f = data.find!(it => it.personId == id);
    if(f.empty) {
        return Nullable!(T).init;
    } else {
        return nullable(f.front); // failing line
    }
}
```

file.d(6): Error: variable
`rest.excel.mapHelper!(SomeStruct).mapHelper.__copytmp12381` `inout` variables
can only be declared inside `inout` functions

SomeStruct is just that, some struct.

It compiles and works if I rewrite mapHelper ti

```dlang
Nullable!(T) mapHelper(T)(T[] data, long id) {
    auto f = data.find!(it => it.personId == id);
    if(f.empty) {
        return Nullable!(T).init;
    } else {
        T ret = f.front;
        Nullable!(T) tmp;
        tmp = ret;
        return tmp;
    }
}
```

This required a 160 line patch today for work.

--


More information about the Digitalmars-d-bugs mailing list