[Issue 12912] Lambda function is incorrectly inferred as impure if it uses member field or function

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Aug 10 06:12:49 PDT 2014


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

--- Comment #2 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to Kenji Hara from comment #1)
> This is not a regression, and a dup of issue 9148.
> 
> *** This issue has been marked as a duplicate of issue 9148 ***

Effectively this is a regression as this code used to work fine:
---
import std.algorithm;
import std.array;

auto makeInoutArray(alias func, T)(inout T[] src)
{
    return cast(inout) func(cast(T[]) src).array();
}

final class C
{
    int f(in uint) pure inout
    { return 1; }
}

final class C2
{
    C[] cs;
    uint var;

    void f() pure inout
    {
        cs.makeInoutArray!(arr => arr
            .map!((c) /*pure*/ => c.f(var))()
            )();
    }
}
---

It may be called a Phobos regression or whatever but it does break code.

How should we deal with such situations, when some bugs prevented some checks
and both correct and incorrect code worked, but introduced fixes rejected both
correct and incorrect codes?

--


More information about the Digitalmars-d-bugs mailing list