Bug 7047 – alias error in struct only for dmd1

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2011-12-01T23:51:00Z
Last change time
2011-12-09T01:53:08Z
Assigned to
nobody
Creator
changlon

Comments

Comment #0 by changlon — 2011-12-01T23:51:08Z
dmd 1.071 error . struct Test1 { alias typeof(this) This; alias This* pThis; int number ; void Init(){ static void Callback (void* user_data){ pThis _this = cast(pThis) user_data; auto i = _this.number ; } } } ------------ test.d(10): Error: no property 'number' for type 'Test1*'
Comment #1 by clugdbug — 2011-12-09T01:53:08Z
This isn't a regression. It gave exactly the same error back in DMD 1.000. In fact, it's not even a bug: in D1, 'this' for a struct is a pointer to that struct. As you can see with this code: struct Test1 { static assert(is(typeof(this) == Test1)); // FAILS !!! } In D2, the 'this' pointer is the struct itself. If you make this change: - alias This* pThis; + alias This pThis; your code will compile.