Skip to content

Commit

Permalink
Merge pull request #6469 from WalterBright/self-assign
Browse files Browse the repository at this point in the history
self-assignment should still allow 'scope' inference
  • Loading branch information
andralex committed Jan 24, 2017
2 parents 6a78739 + 6c640fe commit ad0d63c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/escape.d
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
18 changes: 16 additions & 2 deletions test/fail_compilation/retscope.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -611,4 +626,3 @@ struct Result(R)
n.empty();
}


0 comments on commit ad0d63c

Please sign in to comment.