Thread overview | |||||
---|---|---|---|---|---|
|
May 04, 2018 [Issue 18827] scope delegate literal allocates GC closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18827 Shachar Shemesh <shachar@weka.io> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shachar@weka.io -- |
May 13, 2018 [Issue 18827] scope delegate literal allocates GC closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18827 johanengelen@weka.io changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |industry CC| |johanengelen@weka.io -- |
June 02, 2021 [Issue 18827] scope delegate literal allocates GC closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18827 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dkorpel@live.nl Resolution|--- |INVALID --- Comment #1 from Dennis <dkorpel@live.nl> --- It should allocate a closure, since `func` is free to escape the delegate, e.g.: ``` int delegate(int) global; int func(int delegate(int) dg) { global = dg; return dg(2); } void bar() { int a = 3; scope dg = (int x) => x * a; func(dg); // passing scope dg to non-scope parameter makes bar @system func((int x) scope => x * a); } ``` When marking the input delegate of `func` `scope`, it works: ``` @safe: int func(scope int delegate(int) @safe @nogc dg) @nogc { return dg(2); } void bar() @nogc { int a = 3; scope dg = (int x) => x * a; func(dg); func((int x) scope => x * a); } ``` -- |
Copyright © 1999-2021 by the D Language Foundation