digitalmars.D.bugs - [Issue 16012] New: [REG2.070] forward reference with alias this
- via Digitalmars-d-bugs (64/64) May 10 2016 https://issues.dlang.org/show_bug.cgi?id=16012
https://issues.dlang.org/show_bug.cgi?id=16012 Issue ID: 16012 Summary: [REG2.070] forward reference with alias this Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: rejects-valid Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com This is a reduction of issue 16011. Fixing this possibly also fixes that one, but since this fails with different versions of dmd, there may be something else going on in addition. ---- void emplace(S* chunk) { *chunk = S.init; } struct RefCounted() { struct RefCountedStore { struct Impl { S _payload; } Impl* _store; void initialize() { _store = new Impl; /* line 13 */ emplace(&_store._payload); /* line 14 */ } } RefCountedStore _refCounted; void opAssign(typeof(this) rhs) {} void opAssign(S rhs) {} ref S refCountedPayload() { if (_refCounted._store is null) _refCounted.initialize(); return _refCounted._store._payload; } alias refCountedPayload this; } struct S { int x; RefCounted!() s; } void main() { S s; s.x = 1; s.s.x = 2; s.s.s.x = 3; assert(s.x == 1); assert(s.s.x == 2); assert(s.s.s.x == 3); } ---- 2.069.2: Compiles and passes asserts. 2.070.2, 2.071.0: "test.d(13): Error: struct test.RefCounted!().RefCounted.RefCountedStore.Impl no size yet for forward reference" git master (bc74f4a): "test.d(14): Error: forward reference to (*this._store)._payload" --
May 10 2016