[Issue 19035] New: Escape in scope inference, improve scope inference

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 28 04:47:35 UTC 2018


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

          Issue ID: 19035
           Summary: Escape in scope inference, improve scope inference
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at digitalmars.com

Consider:
----------
@safe:

void escape(int*);

/**********************/

void frank()(ref scope int* p, int* s)
{
    p = s;  // should error here, does not
}

void testfrankly()
{
    int* p;
    int i;
    frank(p, &i);
    // note that p now has a reference to i, and can outlast i
}

/**********************/

void betty()(int* p, int* q)
{
     p = q;
     escape(p);
}

void testbetty()
{
    int i;
    int j;
    betty(&i, &j); // should error on i and j, and it does
}

/**********************/

void archie()(int* p, int* q, int* r)
{
     p = q;
     r = p;
     escape(q);
}

@safe void testarchie()
{
    int i;
    int j;
    int k;
    archie(&i, &j, &k); // should error only on j, not i and j
}
-------

--


More information about the Digitalmars-d-bugs mailing list