Skip to content

Commit

Permalink
fix Issue 17117 - erroneous 'escaping reference to local variable'
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 25, 2017
1 parent ad0d63c commit 4a4dcf2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/fail_compilation/retscope.d
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ void foo18()
typeof(&c.funcrs) fs4 = &c.funcrs;
}


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

@safe void foo19(C)(ref C[] str) // infer 'scope' for 'str'
Expand All @@ -607,6 +606,7 @@ void foo18()

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


bool foo20(const string a) @safe pure nothrow @nogc
{
return !a.length;
Expand All @@ -626,3 +626,25 @@ struct Result(R)
n.empty();
}

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

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

ref int foo21(return ref int s)
{
return s;
}

int fail21()
{
int s;
return foo21(s); // Error: escaping reference to local variable s
}

int test21()
{
int s;
s = foo21(s);
return s;
}

0 comments on commit 4a4dcf2

Please sign in to comment.