On Sunday, 23 February 2020 at 03:26:17 UTC, Steven Schveighoffer
wrote:
On 2/22/20 10:01 PM, Russ wrote:
Is there some newer feature I should be using?
scope escapes are only disallowed in @safe code.
Adding @safe: to the top of this file makes it not compile with
a complaint:
Error: scope variable z assigned to non-scope b.foo
Which I think is what you expected.
As to why it happens without @safe, you may be managing your
global variable carefully and ensuring it's unset by the time
foo goes away. The compiler can't know.
Another reason to enable safe-by-default...
-Steve
Perfect, thank you! I agree that this sort of thing should be on
by default. Better to opt-out than opt-in for memory safety.