D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19782 - `alias this` appends `null` instead of inner/aliased element to array
Summary: `alias this` appends `null` instead of inner/aliased element to array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-03-31 18:40 UTC by Michael Rodacki
Modified: 2019-04-03 12:33 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Michael Rodacki 2019-03-31 18:40:06 UTC
import std.stdio;

class Inner {}

class Outer {
  Inner inner; alias inner this;
  this(Inner i) { inner = i; }
}

void main() {
  Inner[] inners = [];
  inners ~= new Inner;
  inners ~= new Outer(new Inner); // Appends null
  
  foreach(inner; inners){
    writeln(">> ", inner);
  }
}


---

Output from https://run.dlang.io/ with all dmd compilers:

Up to      2.083.1: Success with output:
-----
>> onlineapp.Inner
>> onlineapp.Inner
-----

Since      2.084.0: Success with output:
-----
>> onlineapp.Inner
>> null
-----
Comment 1 Dlang Bot 2019-04-03 10:39:24 UTC
@RazvanN7 created dlang/dmd pull request #9550 "Fix Issue 19782 - alias this appends null instead of inner/aliased element to array" fixing this issue:

- Fix Issue 19782 - alias this appends null instead of inner/aliased element to array

https://github.com/dlang/dmd/pull/9550
Comment 2 Dlang Bot 2019-04-03 12:33:50 UTC
dlang/dmd pull request #9550 "Fix Issue 19782 - alias this appends null instead of inner/aliased element to array" was merged into master:

- 520e5fc638319273de0514706cd87045d13e7d81 by RazvanN7:
  Fix Issue 19782 - alias this appends null instead of inner/aliased element to array

https://github.com/dlang/dmd/pull/9550