<div>Greetings</div><div><br></div><div>Kindly take a look at the code below. I am using alias this with a function that returns by value. I believe in such cases the alias should not take affect when an instance of foo is being used as an lvalue. As a result elements of bar should not have been visible inside the constructor of foo.</div>
<div><br></div><div>Please comment. Is this a bug?</div><div><br></div><div>Regards</div><div>- Puneet</div><div><br></div><div>struct bar (bool B, N...) {</div><div> int n = 0;</div><div>}</div><div><br></div><div>struct foo (N...) {</div>
<div> bar!(true, N) _bar = void;</div><div> </div><div> bar!(true, N) getN() {</div><div> return _bar;</div><div> }</div><div><br></div><div> alias getN this;</div><div><br></div><div> public this(T) (T other)</div>
<div> if (is(T unused : int)) {</div><div> n = other;</div><div> }</div><div>}</div><div><br></div><div><br></div><div>void main() {</div><div> import std.stdio;</div><div> foo!8 a = 42;</div><div> writeln(a.n);</div>
<div>}</div><div><br></div>