digitalmars.D.bugs - [Issue 14583] New: std.typecons.Rebindable works incorrectly with
- via Digitalmars-d-bugs (32/32) May 14 2015 https://issues.dlang.org/show_bug.cgi?id=14583
https://issues.dlang.org/show_bug.cgi?id=14583 Issue ID: 14583 Summary: std.typecons.Rebindable works incorrectly with classes in which there is an 'alias this' to AA member. Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: japplegame gmail.com I spent several hours to discover this very weird bug. :( import std.typecons; class Foo { string[int] aa; } class Bar { string[int] aa; alias aa this; } void main() { auto foo = new immutable Foo; assert(rebindable(foo).get is foo); // ok auto bar = new immutable Bar; assert(rebindable(bar).get is bar); // fails auto len = rebindable(bar).aa.length; // crash } Sometimes 'alias this' is very dangerous thing. --
May 14 2015