Safe Regions with Deterministic Destruction

Per Nordlöw per.nordlow at gmail.com
Mon Oct 26 21:10:21 UTC 2020


On Monday, 26 October 2020 at 19:47:57 UTC, Per Nordlöw wrote:
> What's the reasoning behind disallowing g() but not f()? Lack 
> of `scope`-inference in the compiler? Calling f() will result 
> in a memory error aswell.

Reduced:

class Node {}

struct Tree
{
     Node root;
}

@safe unittest
{
     Node f() { auto  t = Tree(); return t.root; } // shouldn't 
this error aswell?
     Node g() { scope t = Tree(); return t.root; } // errors
}


More information about the Digitalmars-d mailing list