File tree Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Expand file tree Collapse file tree 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -2792,6 +2792,15 @@ struct Nullable(T)
27922792 }
27932793 }
27942794
2795+ this (ref return scope inout Nullable! T rhs) inout
2796+ {
2797+ _isNull = rhs._isNull;
2798+ if (! _isNull)
2799+ _value.payload = rhs._value.payload;
2800+ else
2801+ _value = DontCallDestructorT.init;
2802+ }
2803+
27952804 /**
27962805 * If they are both null, then they are equal. If one is null and the other
27972806 * is not, then they are not equal. If they are both non-null, then they are
@@ -3284,11 +3293,11 @@ auto nullable(T)(T t)
32843293 static struct S2 //inspired from 9404
32853294 {
32863295 Nullable! int ni;
3287- this (S2 other)
3296+ this (ref S2 other)
32883297 {
32893298 ni = other.ni;
32903299 }
3291- void opAssign (S2 other)
3300+ void opAssign (ref S2 other)
32923301 {
32933302 ni = other.ni;
32943303 }
@@ -9566,3 +9575,21 @@ unittest
95669575 assert ((a ^ true ) == Ternary.no);
95679576 assert ((a ^ false ) == Ternary.yes);
95689577}
9578+
9579+ // https://issues.dlang.org/show_bug.cgi?id=22511
9580+ @safe unittest
9581+ {
9582+ static struct S
9583+ {
9584+ int b;
9585+ @disable this (this );
9586+ this (ref return scope inout S rhs) inout
9587+ {
9588+ this .b = rhs.b + 1 ;
9589+ }
9590+ }
9591+
9592+ Nullable! S s1 = S(1 );
9593+ Nullable! S s2 = s1;
9594+ assert (s2.get ().b > s1.get ().b);
9595+ }
You can’t perform that action at this time.
0 commit comments