digitalmars.D.bugs - [Issue 16054] New: can break immutable with std.typecons.Rebindable
- via Digitalmars-d-bugs (32/32) May 21 2016 https://issues.dlang.org/show_bug.cgi?id=16054
https://issues.dlang.org/show_bug.cgi?id=16054 Issue ID: 16054 Summary: can break immutable with std.typecons.Rebindable Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com ---- 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. --
May 21 2016