Thread overview
[Issue 20077] Bogus 'need this' for lambda used inside struct
Jul 23, 2019
Simen Kjaeraas
Oct 19, 2020
Luís Ferreira
Oct 19, 2020
Luís Ferreira
Dec 17, 2022
Iain Buclaw
July 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20077

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
           Severity|enhancement                 |normal

--
October 19, 2020
https://issues.dlang.org/show_bug.cgi?id=20077

Luís Ferreira <lsferreira169@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lsferreira169@gmail.com

--- Comment #1 from Luís Ferreira <lsferreira169@gmail.com> ---
This also happens on accessing static fields on a struct.

auto foobar(alias func)(string val)
{
    return func(val);
}

struct S {
    static immutable foo = "foo";
    static immutable bar = foobar!((v) => v[0])(S.foo);
}

--
October 19, 2020
https://issues.dlang.org/show_bug.cgi?id=20077

--- Comment #2 from Luís Ferreira <lsferreira169@gmail.com> ---
This seems related to what's happening on #21332.

When type is explicitly known on the lambda, this doesn't happen. See this snippet here:

```d
auto foobar(alias func)(string val)
{
    return func(val);
}

struct S {
    static immutable foo = "foo";
    static immutable bar = foobar!((string v) => v[0])(S.foo);
}
```

This is the exact same code snippet reported on the latest comment, but the type of `v` is explicitly declared.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20077

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
February 02, 2023
https://issues.dlang.org/show_bug.cgi?id=20077

Steven Schveighoffer <schveiguy@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@gmail.com
           Hardware|x86                         |All
                 OS|Windows                     |All

--