This one is definitely caused by Bug 7295, but I'm reporting it as a separate issue because the effect on Phobos is a regression. The regression should be fixed for next release come Hell or high water, even if 7295 is not fixed and we have to resort to a workaround.
import std.algorithm, std.typecons;
void main() {
RefCounted!int a, b;
swap(a, b);
}
std\algorithm.d(1491): Error: pure function 'swap' cannot call impure function 'refCountedPayload'
Comment #1 by andrei — 2012-01-22T08:16:23Z
This is a compiler issue that I reduced to this:
struct S
{
int member;
@property ref int refCountedPayload() { return member; }
alias refCountedPayload this;
}
void foo(S, T, Tdummy=void)(ref const S source, ref const T target) @trusted pure nothrow
{
}
// for shared objects
void foo(S, T)(ref const shared S source, ref const shared T target) @trusted pure nothrow
{
alias foo!(shared(S), shared(T), void) ptsTo; // do instantiate explicitly
ptsTo(source, target);
}
void bar(T)(ref T lhs, ref T rhs) @trusted pure nothrow
{
foo(lhs, rhs);
}
void main() {
S a, b;
bar(a, b);
}