July 11, 2020 [Issue 21039] New: `alias this` returns 'null' for ref types when put into array initializer | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21039 Issue ID: 21039 Summary: `alias this` returns 'null' for ref types when put into array initializer Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: m.rodacki@gmx.de class Inner {} class Outer { Inner inner; alias inner this; this(Inner i) { inner = i; } } void main() { auto inner = new Inner; auto outer = new Outer(new Inner); Inner[] inners = [inner, outer]; assert(inners[0], "first element is null"); assert(inners[1], "second element is null"); } --- Output from https://run.dlang.io/is/gfy34l with all d compilers selected Up to 2.083.1: Success and no output 2.084.1: Failure with output: ----- core.exception.AssertError@onlineapp.d(16): second element is null ---------------- ??:? _d_assert_msg [0x429018] onlineapp.d:16 _Dmain [0x427fbb] ----- 2.085.1: Failure with output: ----- core.exception.AssertError@onlineapp.d(16): second element is null ---------------- ??:? _d_assert_msg [0x42c5ca] onlineapp.d:16 _Dmain [0x42b53e] ----- 2.086.1: Failure with output: ----- core.exception.AssertError@onlineapp.d(16): second element is null ---------------- ??:? _d_assert_msg [0x42e27a] onlineapp.d:16 _Dmain [0x42d1ee] ----- 2.087.1: Failure with output: ----- core.exception.AssertError@onlineapp.d(16): second element is null ---------------- ??:? _d_assert_msg [0x43040a] onlineapp.d:16 _Dmain [0x42f23e] ----- Since 2.088.0: Failure with output: ----- core.exception.AssertError@onlineapp.d(16): second element is null ---------------- ??:? _d_assert_msg [0x430352] onlineapp.d:16 _Dmain [0x42f2ce] ----- --- This also appears on dmd v2.092.0 / linux The issue does appear when the inner type is a class or a pointer. Value types work fine. Remotely related but not to be confused with: Issue 19782 -- |
Copyright © 1999-2021 by the D Language Foundation