Thread overview | |||||
---|---|---|---|---|---|
|
February 02, 2023 [Issue 23667] [REG2.101] Incorrect escape deprecation on scope lazy pointer parameter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23667 johanengelen@weka.io changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |industry, rejects-valid -- |
February 03, 2023 [Issue 23667] [REG2.101] Incorrect escape deprecation on scope lazy pointer parameter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23667 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- The compiler essentially rewrites the code to: ``` struct S { this(ref int i) { DBG(() => &i); } } void DBG(scope int* delegate() args) {} ``` So it essentially attaches scope to args no to the return type of args (as far as I understand it doesn't make sense to attach scope on a return type), therefore the scoping information is lost and the compiler is conservative and doesn't let you do that. I guess the compiler should first perform escape analysis before lowering i to a delegate. -- |
February 03, 2023 [Issue 23667] [REG2.101] Incorrect escape deprecation on scope lazy pointer parameter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23667 --- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> --- Actually, it turns out you can escape i: struct S { this(ref int i) { DBG(&i); } } int* delegate() outer; void DBG(lazy scope int* args) { outer = &args; } void main() { int b; S s = S(b); import std.stdio; writeln(*outer()); } It seems that scope is not propagated on the extracted delegate. -- |
Copyright © 1999-2021 by the D Language Foundation