diff --git a/src/escape.d b/src/escape.d index 7acea3985972..2c657952c4ce 100644 --- a/src/escape.d +++ b/src/escape.d @@ -221,6 +221,9 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag) if (v.isDataseg()) continue; + if (v == va) + continue; + Dsymbol p = v.toParent2(); if (!(va && va.isScope())) diff --git a/test/fail_compilation/retscope.d b/test/fail_compilation/retscope.d index 5d321a308e57..48dc5663977a 100644 --- a/test/fail_compilation/retscope.d +++ b/test/fail_compilation/retscope.d @@ -589,8 +589,23 @@ void foo18() typeof(&c.funcrs) fs4 = &c.funcrs; } -/********************************************/ +/*********************************************/ + +@safe void foo19(C)(ref C[] str) // infer 'scope' for 'str' +{ + str = str; + str = str[1 .. str.length]; +} + +@safe void test19() +{ + char[10] s; + char[] t = s[]; + foo19(t); +} + +/********************************************/ bool foo20(const string a) @safe pure nothrow @nogc { @@ -611,4 +626,3 @@ struct Result(R) n.empty(); } -