[Issue 15413] Foreach over range with @disable this doesn't work

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 30 09:15:32 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15413

--- Comment #1 from ZombineDev <petar.p.kirov at gmail.com> ---
I wonder if the solution could be as simple* as changing the lowering to:

for ( ; !ir.empty; ir.popFront()) {
    auto v = __r.front;
}

That way foreach will work with truly input-only ranges (such as ones with
@disabled this(this)) and the users could optionally insert a .save call, if
needed, when they're working with forward ranges.

If this is an unacceptable breaking change, we could use the new lowering only
when the postblit is disabled.

* I'm not very familiar the compiler internals, so I have no idea if this would
be actually simple in practice.

--


More information about the Digitalmars-d-bugs mailing list