fixed another stack error

This commit is contained in:
CPunch 2020-11-12 16:23:56 -06:00
parent 65662e94f2
commit 93130ede65
2 changed files with 2 additions and 2 deletions

View File

@ -763,7 +763,7 @@ static void popLocals(CParseState *pstate, int toScope) {
int localsToPop = 0;
while (pstate->compiler->localCount > 0 && pstate->compiler->locals[pstate->compiler->localCount - 1].depth > toScope) {
Local *local = &pstate->compiler->locals[localsToPop];
Local *local = &pstate->compiler->locals[pstate->compiler->localCount - 1];
if (local->isCaptured) { // local needs to be closed over so other closures can reference it
// first though, if there are other locals in queue to pop first, go ahead and pop those :)

View File

@ -171,7 +171,7 @@ COSMOVMRESULT cosmoV_call(CState *state, int args) {
// execute
if (!cosmoV_execute(state))
return COSMOVM_RUNTIME_ERR;
CValue* result = state->top;
CValue* result = state->top - 1;
// pop the callframe and return result
popCallFrame(state);