There is a compile error for an implicitly typed lambda expression inside a class.
import std.algorithm : map;
auto a = [1,2,3].map!(i => i);
class X {
static auto b = [1,2,3].map!((int i) => i);
// /usr/include/dmd/phobos/std/algorithm/iteration.d(455): Error: this.__lambda4 has no value
static auto c = [1,2,3].map!(i => i);
}
`a` and `b` compile just fine, but `c` causes a compile error. (The error message doesn't indicate what caused it, though.)
Comment #1 by john.loughran.colvin — 2016-06-02T17:47:17Z
I just hit this as well in slightly different circumstances. It appears to be a long-standing bug, I couldn't find an older compiler version that it worked with (haven't tried bisecting though).
I'm pretty sure it's ctfe specific.
Comment #2 by greensunny12 — 2016-08-14T16:04:30Z
Uranuz from D.learn also hit this bug - in his/her case for structs:
http://forum.dlang.org/post/[email protected]
struct A
{
import std.algorithm: map;
import std.array: array;
import std.typecons: tuple;
static immutable aaa = [
tuple("1", "one"),
tuple("2", "two"),
tuple("3", "three")
];
static immutable bbb = aaa.map!( a => a[0] ).array;
}
void main()
{
A a = A();
}
//---------
Compilation output:
/opt/compilers/dmd2/include/std/algorithm/iteration.d(455): Error: this.__lambda6 has no value
> I'm pretty sure it's ctfe specific.
On DMD nightly you even get a better error message saying that am error during CTFE happened :/
Comment #3 by robert.schadek — 2024-12-13T18:47:26Z