ranges reading garbage

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 16 05:30:36 PST 2015


On Sunday, 15 February 2015 at 22:38:20 UTC, anonymous wrote:
> And more:
>
> import std.stdio;
> struct MapResult(alias fun)
> {
>     @property int front() {return fun();}
>     @property auto save() {return typeof(this)();}
> }
> void main()
> {
>     int ys_length = 4;
>     auto dg = {return MapResult!({return ys_length;})();};
>     writeln(dg().front); /* 4, correct */
>     writeln(dg().save.front); /* garbage */
> }

It's already in bugzilla: 
https://issues.dlang.org/show_bug.cgi?id=9685


More information about the Digitalmars-d-learn mailing list