[Issue 19097] Extend Return Scope Semantics

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 18 06:31:16 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19097

--- Comment #3 from Mike Franklin <slavo5150 at yahoo.com> ---

Example 2
---------
@safe:

void betty(ref scope int* r, return scope int* p) 
{ 
    r = p; // (1) Error: scope variable `p` assigned to `r` with longer
lifetime
} 

void main()
{
    int* p;
    int i;
    int* q;

    betty(q, &i); // (2) ok
    betty(p, &i); // (3) should be error
}

Compile with -dip1000:  https://run.dlang.io/is/t6wj71

So, I'm assuming (1) should not be an error because it depends on the lifetimes
of the arguments supplied by the caller.  Correct?

--


More information about the Digitalmars-d-bugs mailing list