diff options
author | Peter Zhu <[email protected]> | 2023-10-30 14:00:49 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-10-31 12:07:54 -0400 |
commit | 1c45124c497089fa310c13ee4b9ea1d3ec2c2ca8 (patch) | |
tree | d2d04726521bad24b5112db6bdd00e4e059daeab /variable.c | |
parent | 6f5e378057a02dadbb0173072f69c8a3f30f5649 (diff) |
Create table for too complex generic variables
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/variable.c b/variable.c index aa1b61ee50..b0bb295369 100644 --- a/variable.c +++ b/variable.c @@ -1424,7 +1424,8 @@ rb_complex_ivar_set(VALUE obj, ID id, VALUE val) break; default: if (!rb_gen_ivtbl_get(obj, 0, (struct gen_ivtbl **)&table)) { - rb_bug("Object should have a gen_iv entry"); + table = st_init_numtable(); + st_insert(generic_ivtbl(obj, id, false), (st_data_t)obj, (st_data_t)table); } } @@ -1500,7 +1501,9 @@ generic_ivar_set(VALUE obj, ID id, VALUE val) index = shape->next_iv_index; next_shape = rb_shape_get_next(shape, obj, id); if (next_shape->type == SHAPE_OBJ_TOO_COMPLEX) { - rb_evict_ivars_to_hash(obj, shape); + if (shape->next_iv_index > 0) { + rb_evict_ivars_to_hash(obj, shape); + } rb_complex_ivar_set(obj, id, val); rb_shape_set_shape(obj, next_shape); FL_SET_RAW(obj, FL_EXIVAR); |