Testcase:
```
auto invoker(Dlg)(scope Dlg dlg) { return dlg; } // <--- `return` is inferred on parameter
// Does not compile, but should.
@nogc void f(int x) { invoker({x++;}); } // <--- return value is discarded, hence does not escape the scope.
// This compiles fine, without gc allocation:
@nogc void g(int x) {
scope inv = invoker({x++;});
inv();
}
```
Compilation succeeds with 2.096, fails with 2.097 with the error:
<source>(3): Error: function `example.f` is `@nogc` yet allocates closures with the GC
<source>(3): example.f.__lambda2 closes over variable x at <source>(3)
C
The regression is related to the fix for https://issues.dlang.org/show_bug.cgi?id=21912
Comment #1 by robert.schadek — 2024-12-13T19:23:33Z