# HG changeset patch # User Tomas Lindquist Olsen # Date 1228831021 -3600 # Node ID 94ba810ea2b0dd951054028b7c6299428f3d2a01 # Parent 331a176c1f4fd6f46a78040eb23593951210b5e8 Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 . diff -r 331a176c1f4f -r 94ba810ea2b0 gen/functions.cpp --- a/gen/functions.cpp Tue Dec 09 14:07:30 2008 +0100 +++ b/gen/functions.cpp Tue Dec 09 14:57:01 2008 +0100 @@ -771,24 +771,31 @@ if (!fd->nestedVars.empty()) { Logger::println("has nested frame"); - // start with add all enclosing parent frames + // start with adding all enclosing parent frames until a static parent is reached int nparelems = 0; - Dsymbol* par = fd->toParent2(); - while (par) + if (!fd->isStatic()) { - if (FuncDeclaration* parfd = par->isFuncDeclaration()) + Dsymbol* par = fd->toParent2(); + while (par) { - nparelems += parfd->nestedVars.size(); + if (FuncDeclaration* parfd = par->isFuncDeclaration()) + { + nparelems += parfd->nestedVars.size(); + // stop at first static + if (parfd->isStatic()) + break; + } + else if (ClassDeclaration* parcd = par->isClassDeclaration()) + { + // nothing needed + } + else + { + break; + } + + par = par->toParent2(); } - else if (ClassDeclaration* parcd = par->isClassDeclaration()) - { - // nothing needed - } - else - { - break; - } - par = par->toParent2(); } int nelems = fd->nestedVars.size() + nparelems; diff -r 331a176c1f4f -r 94ba810ea2b0 tests/mini/compile_nested2.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/compile_nested2.d Tue Dec 09 14:57:01 2008 +0100 @@ -0,0 +1,13 @@ +void test(void delegate() spam) +{ + static void foo() // static is the problem + { + uint x; + void peek() { x = 0; } + } + + void bar() + { + spam(); + } +}