diff --git a/dmd/interpret.c b/dmd/interpret.c index 2cf108de..e4f55964 100644 --- a/dmd/interpret.c +++ b/dmd/interpret.c @@ -56,6 +56,7 @@ Expression *interpret_values(InterState *istate, Expression *earg, FuncDeclarati ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Type *type, Expression *elem, size_t dim); Expression * resolveReferences(Expression *e, Expression *thisval, bool *isReference = NULL); Expression *getVarExp(Loc loc, InterState *istate, Declaration *d); +VarDeclaration *findParentVar(Expression *e, Expression *thisval); /************************************* * Attempt to interpret a function given the arguments. @@ -222,9 +223,9 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument } } // Don't restore the value of 'this' upon function return - if (needThis() && thisarg->op == TOKvar && istate) + if (needThis() && istate) { - VarDeclaration *thisvar = ((VarExp *)(thisarg))->var->isVarDeclaration(); + VarDeclaration *thisvar = findParentVar(thisarg, istate->localThis); for (size_t i = 0; i < istate->vars.dim; i++) { VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; if (v == thisvar) diff --git a/dmd/mtype.c b/dmd/mtype.c index db3de6b9..2e289bef 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -2413,6 +2413,7 @@ Type *TypeAArray::semantic(Loc loc, Scope *sc) switch (next->toBasetype()->ty) { case Tfunction: + case Tvoid: case Tnone: error(loc, "can't have associative array of %s", next->toChars()); break;