Skip to content

Commit

Permalink
Merge pull request #1817 from 9rnsr/fix9834
Browse files Browse the repository at this point in the history
[REG2.063] Issue 9834 - incorrect detection of lambda locality.
  • Loading branch information
WalterBright committed Mar 30, 2013
2 parents 15a6c77 + ac859ee commit 767a029
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mtype.c
Expand Up @@ -6112,7 +6112,7 @@ bool TypeFunction::parameterEscapes(Parameter *p)
if (!nextOf())
return TRUE;

if (purity)
if (purity > PUREweak)
{ /* With pure functions, we need only be concerned if p escapes
* via any return statement.
*/
Expand Down
25 changes: 25 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -6105,6 +6105,30 @@ void test9700()
a *= 3; // object.Error: Access Violation
}

/***************************************************/
// 9834

struct Event9834
{
void delegate() dg;
void set(void delegate() h) pure { dg = h; } // AV occurs
void call() { dg(); }
}
void test9834()
{
Event9834 ev;
auto a = new class
{
Object o;
this()
{
o = new Object;
ev.set((){ o.toString(); });
}
};
ev.call();
}

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

int main()
Expand Down Expand Up @@ -6367,6 +6391,7 @@ int main()
test9428();
test9538();
test9700();
test9834();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 767a029

Please sign in to comment.