On 08/31/2016 09:23 PM, Yuxuan Shui wrote:
Correct me if I'm wrong. But I believe this is only true when the source code of function is not available. Otherwise the compiler should always know if a function is actually @nogc or not.
Attributes are only inferred in certain cases where the source code must be available anyway (templates, `auto` return value). For ordinary functions, the compiler only considers them @nogc when they're explicitly marked.
For example, the compiler won't let you do this, even though f's source code is available and it's obviously de-facto @nogc:
---- void f() {} void main() @nogc { f(); } ----