https://issues.dlang.org/show_bug.cgi?id=21341
Dennis <dkor...@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |safe Status|NEW |RESOLVED CC| |dkor...@live.nl Resolution|--- |INVALID --- Comment #2 from Dennis <dkor...@live.nl> --- The code compiles now because the check is no longer performed in `@system` code, but the error comes back when you add `@safe:`. However, the behavior is as intended, and comes down to the infamous 'scope is not transitive' limitation. > The `return` on parameter `watcher` means that the reference escapes to the > `this` parameter. `scope` on `this` applies to the array (`watchers.ptr`), not any pointers in the array elements. Line 13 is equivalent to: ```D this.watchers ~= [A(&watcher.func)]; ``` And the problem isn't the `this.watchers ~=` part, but the `[A(&watcher.func)];` part putting it into a GC array literal (the 'allocated memory' that the error talks about) --