No GC is actually used here: void f(bool cond, string s) @nogc { auto inner() { return s; } alias Unused1 = typeof(inner); // OK alias Unused2 = typeof(&inner); // INFERS GC } This is especially interesting when trying to use functionAttribute!inner and others that internally "take address" (not really) of the given function and wrongly infer GC is needed.
@maxhaton created dlang/dmd pull request #14195 "Fix Issue 19285 - False GC positive caused by AddressOf inside typeof…" fixing this issue: - Fix Issue 19285 - False GC positive caused by AddressOf inside typeof polluting global semantic state. https://github.com/dlang/dmd/pull/14195
dlang/dmd pull request #14195 "Fix Issue 19285 - False GC positive caused by AddressOf inside typeof…" was merged into master: - b06afb8bfebbb31d675171c7e7840bf0d40155e0 by mhh: Fix Issue 19285 - False GC positive caused by AddressOf inside typeof polluting global semantic state. This patch also adds a new method isFromSpeculativeSemanticContext to the Scope struct to avoid repition of this logic in the compiler. https://github.com/dlang/dmd/pull/14195