From 058ebda4b77363ec4f78ef561de9db4b4be7b827 Mon Sep 17 00:00:00 2001 From: William Langford Date: Wed, 23 Oct 2019 13:29:08 -0400 Subject: [PATCH] Increment nlocals when compiling STORE_GLOBAL ops These are stored in vars, so we need to make sure that nlocals is large enough to account for that --- src/compile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compile.c b/src/compile.c index 7706c23663..5fccfdb705 100644 --- a/src/compile.c +++ b/src/compile.c @@ -1347,6 +1347,7 @@ static int compile(struct bytecode* bc, block b, struct locfile* lf, jv args, jv code[pos++] = nesting_level(bc, curr->bound_by); uint16_t var = (uint16_t)curr->bound_by->imm.intval; code[pos++] = var; + if (var > maxvar) maxvar = var; } else if (op->flags & OP_HAS_CONSTANT) { code[pos++] = jv_array_length(jv_copy(constant_pool)); constant_pool = jv_array_append(constant_pool, jv_copy(curr->imm.constant));