mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-20 04:10:18 +02:00
Fixed crash in DtoCreateNestedContextType().
In some cases, like the following, DtoDeclareFunction() hasn't already been called when DtoCreateNestedContextType() is invoked. This seems to have been anticipated when the function was originally written, but DtoDeclareFunction() was previously called after the ir func was already accessed in fd->ir.irFunc->nestedContextCreated.
---
void main() {
mixin({
string foo() {
return "";
}
string bar()() {
return foo();
}
return bar();
}());
}
---
This commit is contained in:
+5
-1
@@ -365,12 +365,15 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
|||||||
Logger::println("DtoCreateNestedContextType for %s", fd->toChars());
|
Logger::println("DtoCreateNestedContextType for %s", fd->toChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
|
||||||
|
#if DMDV2
|
||||||
|
DtoDeclareFunction(fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (fd->ir.irFunc->nestedContextCreated)
|
if (fd->ir.irFunc->nestedContextCreated)
|
||||||
return;
|
return;
|
||||||
fd->ir.irFunc->nestedContextCreated = true;
|
fd->ir.irFunc->nestedContextCreated = true;
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
DtoDeclareFunction(fd);
|
|
||||||
if (fd->nestedVars.empty()) {
|
if (fd->nestedVars.empty()) {
|
||||||
// fill nestedVars
|
// fill nestedVars
|
||||||
size_t nnest = fd->closureVars.dim;
|
size_t nnest = fd->closureVars.dim;
|
||||||
@@ -381,6 +384,7 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nestedCtx == NCHybrid) {
|
if (nestedCtx == NCHybrid) {
|
||||||
// construct nested variables array
|
// construct nested variables array
|
||||||
if (!fd->nestedVars.empty())
|
if (!fd->nestedVars.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user