Safe Regions with Deterministic Destruction
ag0aep6g
anonymous at example.com
Tue Oct 27 06:16:56 UTC 2020
On 26.10.20 22:10, Per Nordlöw wrote:
> 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
> }
You've reduced that a bit too much. There's nothing unsafe left in the
code. `g` only errors, because you're using `scope` to tell the compiler
that `t.root` is dangerous (when it's not actually).
More information about the Digitalmars-d
mailing list