[Issue 14583] New: std.typecons.Rebindable works incorrectly with classes in which there is an 'alias this' to AA member.
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu May 14 08:53:44 PDT 2015
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 at puremagic.com
Reporter: japplegame at 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.
--
More information about the Digitalmars-d-bugs
mailing list