From 9e6bc30b0997867d21b794b933cbf822e7d8cfa6 Mon Sep 17 00:00:00 2001 From: k-hara Date: Tue, 7 Jul 2015 18:15:24 +0900 Subject: [PATCH] fix Issue 14779 - incorrect addressing of arguments in require/in-contract --- src/func.c | 6 +++--- test/runnable/testcontracts.d | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/func.c b/src/func.c index a15d4d9aac71..93355e8a9f93 100644 --- a/src/func.c +++ b/src/func.c @@ -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()) diff --git a/test/runnable/testcontracts.d b/test/runnable/testcontracts.d index 0092d3a62e21..a1b9e74b6c27 100644 --- a/test/runnable/testcontracts.d +++ b/test/runnable/testcontracts.d @@ -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() @@ -772,6 +791,7 @@ int main() test8073(); test8093(); test9383(); + test14779(); printf("Success\n"); return 0;