Function literals start again at nesting depth zero.

GitHub: Fixes #447.
This commit is contained in:
David Nadlinger 2013-09-12 13:47:54 +02:00
parent e5463f77b7
commit 243146199f

View file

@ -319,7 +319,13 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
LLStructType* innerFrameType = NULL;
unsigned depth = -1;
if (!fd->isStatic()) {
// Static functions and function (not delegate) literals don't allow
// access to a parent context, even if they are nested.
const bool certainlyNewRoot = fd->isStatic() ||
(fd->isFuncLiteralDeclaration() &&
static_cast<FuncLiteralDeclaration*>(fd)->tok == TOKfunction);
if (!certainlyNewRoot) {
if (FuncDeclaration* parfd = getParentFunc(fd, true)) {
// Make sure the parent has already been analyzed.
DtoCreateNestedContextType(parfd);