From 860f30f201a70f16f792356fa440d59b2f3d9972 Mon Sep 17 00:00:00 2001 From: CPunch Date: Tue, 5 Jan 2021 22:46:04 -0600 Subject: [PATCH] removed printStack() from cosmoB_pcall() --- src/cbaselib.c | 1 - src/cvm.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cbaselib.c b/src/cbaselib.c index b24f953..49d684b 100644 --- a/src/cbaselib.c +++ b/src/cbaselib.c @@ -54,7 +54,6 @@ int cosmoB_pcall(CState *state, int nargs, CValue *args) { // insert false before the result cosmo_insert(state, 0, cosmoV_newBoolean(res == COSMOVM_OK)); - cosmoV_printStack(state); return 2; } diff --git a/src/cvm.c b/src/cvm.c index 4b174d3..257035b 100644 --- a/src/cvm.c +++ b/src/cvm.c @@ -339,9 +339,15 @@ COSMOVMRESULT cosmoV_pcall(CState *state, int args, int nresults) { if (!callCValue(state, *base, args, nresults, 0)) { // restore panic state state->panic = false; - state->error = NULL; - cosmoV_pushValue(state, cosmoV_newObj(state->error)); + if (nresults > 0) { + cosmoV_pushValue(state, cosmoV_newObj(state->error)); + + // push other expected results onto the stack + for (int i = 0; i < nresults-1; i++) + cosmoV_pushValue(state, cosmoV_newNil()); + } + return COSMOVM_RUNTIME_ERR; }