Skip to content

Commit

Permalink
fix Issue 17029 - [Reg 2.072] scope variable may not be returned
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Dec 25, 2016
1 parent ad1e5d3 commit 063bcfc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
9 changes: 6 additions & 3 deletions src/escape.d
Expand Up @@ -91,9 +91,12 @@ private bool checkEscapeImpl(Scope* sc, Expression e, bool refs, bool gag)

if (v.isScope())
{
if (!gag)
error(e.loc, "scope variable %s may not be returned", v.toChars());
result = true;
if (global.params.vsafe) // https://issues.dlang.org/show_bug.cgi?id=17029
{
if (!gag)
error(e.loc, "scope variable %s may not be returned", v.toChars());
result = true;
}
}
else if (v.storage_class & STCvariadic)
{
Expand Down
9 changes: 0 additions & 9 deletions test/fail_compilation/fail7294.d

This file was deleted.

14 changes: 7 additions & 7 deletions test/fail_compilation/fail_scope.d
Expand Up @@ -3,13 +3,6 @@ PERMUTE_ARGS:
REQUIRED_ARGS: -dip25
TEST_OUTPUT:
---
fail_compilation/fail_scope.d(30): Error: scope variable da may not be returned
fail_compilation/fail_scope.d(32): Error: scope variable o may not be returned
fail_compilation/fail_scope.d(33): Error: scope variable dg may not be returned
fail_compilation/fail_scope.d(35): Error: scope variable da may not be returned
fail_compilation/fail_scope.d(37): Error: scope variable o may not be returned
fail_compilation/fail_scope.d(38): Error: scope variable dg may not be returned
fail_compilation/fail_scope.d(40): Error: scope variable p may not be returned
fail_compilation/fail_scope.d(45): Error: escaping reference to local variable string
fail_compilation/fail_scope.d(63): Error: escaping reference to local variable s
fail_compilation/fail_scope.d(74): Error: fail_scope.foo8 called with argument types (int) matches both:
Expand All @@ -23,6 +16,13 @@ fail_compilation/fail_scope.d(108): Error: escaping reference to outer local var
fail_compilation/fail_scope.d(127): Error: escaping reference to local variable s
fail_compilation/fail_scope.d(137): Error: escaping reference to local variable i
---
//fail_compilation/fail_scope.d(30): Error: scope variable da may not be returned
//fail_compilation/fail_scope.d(32): Error: scope variable o may not be returned
//fail_compilation/fail_scope.d(33): Error: scope variable dg may not be returned
//fail_compilation/fail_scope.d(35): Error: scope variable da may not be returned
//fail_compilation/fail_scope.d(37): Error: scope variable o may not be returned
//fail_compilation/fail_scope.d(38): Error: scope variable dg may not be returned
//fail_compilation/fail_scope.d(40): Error: scope variable p may not be returned
*/

alias int delegate() dg_t;
Expand Down

0 comments on commit 063bcfc

Please sign in to comment.