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.
Comment #1 by razvan.nitu1305 — 2018-11-02T11:32:22Z
*** This issue has been marked as a duplicate of issue 13953 ***
Comment #2 by razvan.nitu1305 — 2018-11-02T20:36:09Z
It is not a duplicate of 13953. Reopening.
Comment #3 by robert.schadek — 2024-12-13T18:42:53Z