From e5463f77b7d87ad0581819acc64893cbf1ecf448 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 12 Sep 2013 13:46:45 +0200 Subject: [PATCH] FuncDeclaration::nestedVars should only be filled in DtoCreateNestedContextType. --- gen/nested.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gen/nested.cpp b/gen/nested.cpp index d45b47d0..5aee6af4 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -302,14 +302,13 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) { return; fd->ir.irFunc->nestedContextCreated = true; - if (fd->nestedVars.empty()) { - // fill nestedVars - size_t nnest = fd->closureVars.dim; - for (size_t i = 0; i < nnest; ++i) - { - VarDeclaration* vd = static_cast(fd->closureVars.data[i]); - fd->nestedVars.insert(vd); - } + // fill nestedVars + assert(fd->nestedVars.empty() && "nestedVars should only be filled here"); + size_t nnest = fd->closureVars.dim; + for (size_t i = 0; i < nnest; ++i) + { + VarDeclaration* vd = static_cast(fd->closureVars.data[i]); + fd->nestedVars.insert(vd); } // construct nested variables array