Bug 13623 – std.typecons.Proxy doesn't work inside classes

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-10-16T22:37:00Z
Last change time
2014-11-27T14:38:53Z
Keywords
pull
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2014-10-16T22:37:31Z
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.");
Comment #1 by dev — 2014-10-17T17:04:33Z
What is the rationale for stopping Proxy working with classes? Although i don't have any real use cases, surely it would be better just to fix it to work with classes?
Comment #2 by sweatygarlic — 2014-11-20T14:17:57Z
I wrote a pull request about this issue. Please see : https://github.com/D-Programming-Language/phobos/pull/2740
Comment #3 by k.hara.pg — 2014-11-27T14:38:53Z
(In reply to sweatygarlic from comment #2) > I wrote a pull request about this issue. > Please see : https://github.com/D-Programming-Language/phobos/pull/2740 PR is merged. https://github.com/D-Programming-Language/phobos/commit/06ac5031b1d5de694c45d664a0295f6381c6fb87