​原文​

ref int f(ref return scope int* p) @safe
{
return *p;
}

按​​引用+中域​​​编译,保护​​p​​​值,而非​​p​​​地址,成功编译,因为​​p​​​就是​​返回值​​​.
而:

ref int f(ref scope return int* p) @safe
{
return *p;
}

编译失败.不能返回​​p​​​域变量.行为由​​函数签名​​​,而非​​返回表达式​​​决定.
问题是​​​代码​​​试图存储域保护的​​int*p​​​到未受​​保护​​​的​​*ptr​​​有效负载指针中.而​​dip1000​​​不可能完成.
​​​dip1000​​​的全部意义在于,可在​​@safe​​​代码中使用​​栈分配的数组​​​.
返回​​​ref​​​转换为​​指针​​并解引用来取非区间值.

// 用-preview=dip1000编译.
@safe:
struct Arr
{
int** ptr;

ref int* index() return scope {
return *ptr;
}

void assign(int* p) scope {
*ptr = p;
}
}

void main()
{
scope Arr a;

a.assign(*&a.index());

auto tmp = &a.index();
a.assign(*tmp);
}