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: [email protected]
Reporter: [email protected]
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.
--