From 515260213c480bb275e92c86e82498e96d0fcbb0 Mon Sep 17 00:00:00 2001 From: William Langford Date: Thu, 20 Jul 2023 20:01:16 -0400 Subject: [PATCH] Increment nlocals when compiling STORE_GLOBAL ops (#2000) 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 b713bc3715..58d08573df 100644 --- a/src/compile.c +++ b/src/compile.c @@ -1348,6 +1348,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));