www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22176] New: Nullable creates autogenerated opAssign,


          Issue ID: 22176
           Summary: Nullable creates autogenerated opAssign, triggering
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

import std.typecons;
struct S
    int i;
    invariant(i != 0);

    Nullable!int k;

void main() {
    S s;
    s = S(5);

Previously, that invariant was not a problem because "s = S(5)" is a plain
copy, because no type in or under S requires generated opAssign.

With DMD 2.095.1, Nullable gained an `opAssign()(Nullable!T)` overload. This
means that now, any type that contains a Nullable gets an autogenerated
`opAssign` method, which triggers the invariant check.

"Non-init" is a very common invariant in domain-data, and T.init is a very
common value in ranges, which frequently reassign fields. So this is rather

Since that opAssign was only added to handle the `get` deprecation and `get` is
now removed, maybe it can be reverted?

Aug 04 2021