Skip to content

Commit

Permalink
Merge pull request #6493 from WalterBright/scope-self-ref
Browse files Browse the repository at this point in the history
scope: parameter does not escape through itself
  • Loading branch information
andralex committed Feb 11, 2017
2 parents 041bc9e + 209b82e commit a1c9439
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mtype.d
Expand Up @@ -6652,6 +6652,8 @@ extern (C++) final class TypeFunction : TypeNext
foreach (const i; 0 .. dim)
{
Parameter fparam = Parameter.getNth(parameters, i);
if (fparam == p)
continue;
Type t = fparam.type;
if (!t)
continue;
Expand Down
12 changes: 12 additions & 0 deletions test/fail_compilation/retscope.d
Expand Up @@ -626,6 +626,18 @@ struct Result(R)
n.empty();
}

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

@safe void foo22()(ref char[] s)
{
char[] a = s;
}

@safe void test22(scope char[] s)
{
foo22(s);
}

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

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

0 comments on commit a1c9439

Please sign in to comment.