This fails with 'function `S.test!((a) => a).test` need this to access member test': struct S { pragma(msg, test!(a => a)); } int test(alias fn)() { return fn(3); } Clearly, a => a does not need access to `this` in S, and something's gone wrong in the inference here.
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); }
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.