File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -847,7 +847,7 @@ template Tuple(Specs...)
847847 * source `Tuple` must be implicitly assignable to each
848848 * respective element of the target `Tuple`.
849849 */
850- void opAssign (R)(auto ref R rhs)
850+ ref Tuple opAssign (R)(auto ref R rhs)
851851 if (areCompatibleTuples! (typeof (this ), R, " =" ))
852852 {
853853 import std.algorithm.mutation : swap;
@@ -870,6 +870,7 @@ template Tuple(Specs...)
870870 // Do not swap; opAssign should be called on the fields.
871871 field[] = rhs.field[];
872872 }
873+ return this ;
873874 }
874875
875876 /**
@@ -1802,6 +1803,22 @@ private template ReverseTupleSpecs(T...)
18021803 );
18031804}
18041805
1806+ // Issue 8494, parte uno
1807+ @safe unittest
1808+ {
1809+ auto a = tuple(3 , " foo" );
1810+ assert (__traits(compiles, { a = (a = a); }));
1811+ }
1812+ // Ditto
1813+ @safe unittest
1814+ {
1815+ Tuple ! (int []) a, b, c;
1816+ a = tuple([0 , 1 , 2 ]);
1817+ c = b = a;
1818+ assert (a[0 ].length == b[0 ].length && b[0 ].length == c[0 ].length);
1819+ assert (a[0 ].ptr == b[0 ].ptr && b[0 ].ptr == c[0 ].ptr);
1820+ }
1821+
18051822/**
18061823 Constructs a $(LREF Tuple) object instantiated and initialized according to
18071824 the given arguments.
You can’t perform that action at this time.
0 commit comments