https://issues.dlang.org/show_bug.cgi?id=13623
Issue ID: 13623
Summary: std.typecons.Proxy doesn't work inside classes
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: [email protected]
Reporter: [email protected]
cat > bug.d << CODE
import std.typecons, std.traits;
class Foo
{
private int value;
mixin Proxy!value;
this(int n){ value = n; }
}
unittest
{
auto a = new Foo(10), b = new Foo(10);
assert(a == b); // Proxy should override Object.opEquals
a = 13;
}
CODE
dmd -unittest -main -run bug
----
I think it's reasonable for Proxy to only work inside structs, but there should
be a check in the mixin template.
static assert(!is(typeof(this) == class), "Proxy cannot be used inside
classes.");
--