Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ template Tuple(Specs...)
* source `Tuple` must be implicitly assignable to each
* respective element of the target `Tuple`.
*/
void opAssign(R)(auto ref R rhs)
ref Tuple opAssign(R)(auto ref R rhs)
if (areCompatibleTuples!(typeof(this), R, "="))
{
import std.algorithm.mutation : swap;
Expand All @@ -870,6 +870,7 @@ template Tuple(Specs...)
// Do not swap; opAssign should be called on the fields.
field[] = rhs.field[];
}
return this;
}

/**
Expand Down Expand Up @@ -1802,6 +1803,22 @@ private template ReverseTupleSpecs(T...)
);
}

// Issue 17803, parte uno
@safe unittest
{
auto a = tuple(3, "foo");
assert(__traits(compiles, { a = (a = a); }));
}
// Ditto
@safe unittest
{
Tuple!(int[]) a, b, c;
a = tuple([0, 1, 2]);
c = b = a;
assert(a[0].length == b[0].length && b[0].length == c[0].length);
assert(a[0].ptr == b[0].ptr && b[0].ptr == c[0].ptr);
}

/**
Constructs a $(LREF Tuple) object instantiated and initialized according to
the given arguments.
Expand Down