struct S {
int n;
enum t = tmp!(a => n);
}
string tmp(alias T)() { return ""; }
foo.d(6): Error: function foo.S.tmp!((a) => n).tmp need 'this' to access member tmp
foo.d(3): called from here: tmp()
Notice that the error message claims tmp needs 'this' to access itself. Surely the latter should say 'member n' instead.
Comment #1 by simen.kjaras — 2018-03-09T12:39:39Z
Further simplified:
struct S {
int n;
enum t = tmp!n;
}
string tmp(alias T)() { return ""; }
It seems tmp has to be a function template - reducing it to `enum tmp(alias T) = 1;` removes the error message.
Comment #2 by robert.schadek — 2024-12-13T18:57:43Z