Skip to content

Commit

Permalink
Increment nlocals when compiling STORE_GLOBAL ops (#2000)
Browse files Browse the repository at this point in the history
These are stored in vars, so we need to make sure that nlocals is large
enough to account for that
  • Loading branch information
wtlangford authored Jul 21, 2023
1 parent 3ec66c8 commit 5152602
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 5152602

Please # to comment.