summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorJeremy Evans <[email protected]>2024-01-12 08:58:39 -0800
committerJeremy Evans <[email protected]>2024-03-04 09:49:55 -0800
commit5899f6aa55a02f211545d9cdaef4d86fa0b49528 (patch)
treed7be5119394b86008bbcc7feaa008ff839deb687 /compile.c
parentf7adee34a33c825eef40cf803ebb83f46ff8fc77 (diff)
Keep hidden local variables when dumping and loading iseqs
Fixes [Bug #19975]
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 1336982d32..810e206adf 100644
--- a/compile.c
+++ b/compile.c
@@ -11863,6 +11863,10 @@ ibf_load_id(const struct ibf_load *load, const ID id_index)
return 0;
}
VALUE sym = ibf_load_object(load, id_index);
+ if (rb_type_p(sym, T_FIXNUM)) {
+ /* Load hidden local variables as indexes */
+ return FIX2INT(sym);
+ }
return rb_sym2id(sym);
}
@@ -12386,7 +12390,12 @@ ibf_dump_local_table(struct ibf_dump *dump, const rb_iseq_t *iseq)
int i;
for (i=0; i<size; i++) {
- table[i] = ibf_dump_id(dump, body->local_table[i]);
+ VALUE v = ibf_dump_id(dump, body->local_table[i]);
+ if (v == 0) {
+ /* Dump hidden local variables as indexes, so load_from_binary will work with them */
+ v = ibf_dump_object(dump, ULONG2NUM(size-i+1));
+ }
+ table[i] = v;
}
IBF_W_ALIGN(ID);