@nogc
check fails when there are both nested @nogc
function **and** a closure inside __trait(compiles)
#20917
Labels
Severity:Industry
Code that affects the industry
Here is an example:
This produces an error:
... but if I comment out either line (1) or line (2) it works fine. It also seems to be important that both
foo
and a closure in__trait(compiles)
close over the same variable.It's probably expected, but also worth mentioning that it's not just static analysis, codegen is also affected. If I remove
@nogc
fromtest
declaration, the code compiles, but it does call_d_allocmemory
, while commenting either line (1) or line (2) makes it work without memory allocation.The example in godbolt: https://godbolt.org/z/Wzaq1Tzo7
Kudos to @EyalIO for spotting the bug and to @ljmf00 for making a minimal example.
The text was updated successfully, but these errors were encountered: