Bug 14583 – std.typecons.Rebindable works incorrectly with classes in which there is an 'alias this' to AA member.

Status
REOPENED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-05-14T15:53:44Z
Last change time
2024-12-13T18:42:53Z
Assigned to
No Owner
Creator
Jack Applegame
Moved to GitHub: dmd#18990 →

Comments

Comment #0 by japplegame — 2015-05-14T15:53:44Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18990 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB