Bug 19035 – Escape in scope inference, improve scope inference
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-06-28T04:47:35Z
Last change time
2018-07-01T21:02:36Z
Assigned to
No Owner
Creator
Walter Bright
Comments
Comment #0 by bugzilla — 2018-06-28T04:47:35Z
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
}
-------