the type of f above is not a function pointer type but only a bare function type. You need to place a * before the type. Note that because fonction pointers point to constant data, you also need to place a const.
You already got your answer:
Function-body types can only be used at comptime.
But your original example tried to use them at run-time.
Function-body types are essentially only an identity that represents some function at compile time, once these functions get compiled into a program you can convert that identity to the corresponding pointer to the code of that function (wherever the compiler decides to put it) with the & address operator.
It is a struct field, function fields don’t exist.
The original example doesn’t use the field of function type at run-time.
But maybe you are right, it can be potentially used at run-time, at least from the semantic level. That is why the field needs an explicit comptime annotation.
Yes, you should be able to use the original Foo struct in a comptime var, but aren’t allowed to use it in a normal var, because then you could change the .f field at runtime which is impossible because values of its type don’t exist at runtime.