Skip to content

Commit

Permalink
fix Issue 14779 - incorrect addressing of arguments in require/in-con…
Browse files Browse the repository at this point in the history
…tract
  • Loading branch information
9rnsr committed Jul 7, 2015
1 parent 0e05196 commit 9e6bc30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/func.c
Expand Up @@ -4367,14 +4367,14 @@ bool FuncDeclaration::hasNestedFrameRefs()
if (closureVars.dim)
return true;

/* If a virtual method has contracts, assume its variables are referenced
/* If a virtual function has contracts, assume its variables are referenced
* by those contracts, even if they aren't. Because they might be referenced
* by the overridden or overriding function's contracts.
* This can happen because frequire and fensure are implemented as nested functions,
* and they can be called directly by an overriding function and the overriding function's
* context had better match, or Bugzilla 7337 will bite.
* context had better match, or Bugzilla 7335 will bite.
*/
if ((fdrequire || fdensure) && isVirtualMethod())
if (fdrequire || fdensure)
return true;

if (foverrides.dim && isVirtualMethod())
Expand Down
20 changes: 20 additions & 0 deletions test/runnable/testcontracts.d
Expand Up @@ -753,6 +753,25 @@ class C10981
body {}
}

/*******************************************/
// 14779

class C14779
{
final void foo(int v)
in { assert(v == 0); }
out { assert(v == 0); }
body
{
}
}

void test14779()
{
auto c = new C14779();
c.foo(0);
}

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

int main()
Expand All @@ -772,6 +791,7 @@ int main()
test8073();
test8093();
test9383();
test14779();

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

0 comments on commit 9e6bc30

Please sign in to comment.