Another nested context crash fix.

The test case that would previously crash:

a.d
---
module a;

@property bool empty(T)(in T[] a) {
  return !a.length;
}

void find(alias pred,R1)(R1 haystack) {
  simpleMindedFind!pred(haystack);
}

void simpleMindedFind(alias pred, R1)(R1 haystack) {
  bool haystackTooShort() {
    return haystack.empty;
  }
}
---

b.d
---
module b;

import c;

void getTimeZone() {
  indexOf();
}
---

c.d
---
module c;

import a;

void indexOf()() {
  find!({})("");
}
---
This commit is contained in:
David Nadlinger 2011-08-17 02:31:46 +02:00
parent 11f19eec5a
commit 3f448afa37

View file

@ -392,6 +392,9 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
unsigned depth = -1; unsigned depth = -1;
if (!fd->isStatic()) { if (!fd->isStatic()) {
if (FuncDeclaration* parfd = getParentFunc(fd, true)) { if (FuncDeclaration* parfd = getParentFunc(fd, true)) {
// Make sure parfd->ir.irFunc has already been set.
DtoDeclareFunction(parfd);
innerFrameType = parfd->ir.irFunc->frameType; innerFrameType = parfd->ir.irFunc->frameType;
if (innerFrameType) if (innerFrameType)
depth = parfd->ir.irFunc->depth; depth = parfd->ir.irFunc->depth;