This is a spin-off from issue 17435.
This code should be rejected:
----
struct S { int field; }
template ft(alias a) { int f() { return a; } }
void main()
{
/* ft!(S.field).f(); */ /* correctly rejected */
alias fa = ft!(S.field).f; /* accepted */
/* fa(); */ /* correctly rejected */
int function() fptr = &fa; /* accepted */
int i = fptr(); /* accepted */
}
----
At least one of the "accepted" lines should be rejected.
When ft or f are marked as `static`, the instantiation of ft (the first "accepted" line) gets rejected. Adding `static` like that should not have any effect. The template and the resulting function are already at module level.
Comment #1 by robert.schadek — 2024-12-13T18:52:19Z