Filed this as a new bug report instead of reopening
https://issues.dlang.org/show_bug.cgi?id=20596
-------------------------------------------------------------
[email protected] 2020-08-09 10:30:32 UTC writes:
Reopening, because the regression is not entirely fixed.
See this slightly modified testcase, where variable `s` is not explicitly marked `scoped`. The compiler does not deduce `scope` for `s`. This used to compile and not GC-allocate (<= 2.085) but no longer does.
```
struct S(T) {
void delegate() dg;
this(scope void delegate() dg)
{
this.dg = dg;
}
}
@nogc void fooTemplate() {
int num;
void foo() { int dummy = num; }
auto s = S!int(&foo); // not explicitly defined as `scope`
}
```
and:
Another example that fails compilation:
```
struct S(T) {
void delegate() dg;
this(scope void delegate() dg)
{
this.dg = dg;
}
}
// The explicit `scope` here is not used in `fooTemplate`
@nogc auto dosomething(scope S!int s)
{
}
@nogc auto fooTemplate() {
int num;
void foo() { int dummy = num; }
dosomething(S!int(&foo));
}
```
Comment #1 by robert.schadek — 2024-12-13T19:10:43Z