Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 12, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- As a workaround you can just use Builder.perform. -- |
April 12, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 --- Comment #2 from Richard Cattermole <alphaglosined@gmail.com> --- Yeah I went with ``typeof(builder).perform;`` since the real thing is templated non-trivially. Not ideal for example code though (which is what triggered this). -- |
April 12, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 --- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> --- Looking at the compiler code, it seems that when `builder.perform()` is encountered you have a CallExp that points to a DotIdExp (builder.perform). To analyze it, the compiler first needs to semantically analyze `builder`. Once it does that it also checks whether it is accessed from a nested function and issues the error you are seeing. Between the analysis site of the call exp and the analysis site of `builder` there are multiple calls so at the point where `builder` is analyzed you have no idea whether it comes from a CallExp or a DotIdExp or something else. As such, I think that supporting this case will make the compiler code much uglier (passing a parameter down the call stack or duplicating the code path that analyzes `builder` at at the point of the analysis of the call expression) for a small gain in expressiveness. Since the workaround is very easy, I think that this will most likely be a WONTFIX. -- |
April 13, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 --- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> --- @Rikki ok to close? -- |
April 13, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 --- Comment #5 from Richard Cattermole <alphaglosined@gmail.com> --- It's still a valid bug, even if it may be a little difficult or not worth the time to solve right now. Bug reports like this shouldn't be closed, because they may be worth it to be fixed later on. -- |
April 13, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=23815 --- Comment #6 from Basile-z <b2.temp@gmx.com> --- I think this is a dup of 23815. -- |
April 13, 2023 [Issue 23835] Accessing variable outside nested function creates delegate even if it is static | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23835 --- Comment #7 from Richard Cattermole <alphaglosined@gmail.com> --- *** Issue 23815 has been marked as a duplicate of this issue. *** -- |
Copyright © 1999-2021 by the D Language Foundation