Temporary variables cannot be referenced inside a closure

This commit is contained in:
Alexey Prokhin
2014-01-12 14:13:41 +04:00
parent 6ef20b6123
commit a6973a39b7

View File

@@ -404,7 +404,8 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
// Create frame for current function and append to frames list
// FIXME: alignment ?
LLValue* frame = 0;
if (fd->needsClosure())
bool needsClosure = fd->needsClosure();
if (needsClosure)
frame = DtoGcMalloc(frameType, ".frame");
else
frame = DtoRawAlloca(frameType, 0, ".frame");
@@ -448,6 +449,9 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
I != E; ++I) {
VarDeclaration *vd = *I;
if (needsClosure && vd->needsAutoDtor())
vd->error("has scoped destruction, cannot build closure");
LLValue* gep = DtoGEPi(frame, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
if (vd->isParameter()) {
Logger::println("nested param: %s", vd->toChars());