Bug 16054 – can break immutable with std.typecons.Rebindable
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-21T22:01:00Z
Last change time
2016-10-01T11:45:35Z
Keywords
pull
Assigned to
ag0aep6g
Creator
ag0aep6g
Comments
Comment #0 by ag0aep6g — 2016-05-21T22:01:37Z
----
import std.typecons: Rebindable;
class C
{
int x;
this(int x) pure { this.x = x; }
}
void main()
{
Rebindable!(immutable C) ic = new immutable C(1);
immutable(C)* p = &ic.get();
assert(p.x == 1); /* passes */
scope (exit) assert(p.x == 1); /* fails */
ic = new immutable C(2);
}
----
As far as I see, Rebindable can't be allowed to return a reference to its tail-immutable payload.