diff options
-rw-r--r-- | test/ruby/test_shapes.rb | 3 | ||||
-rw-r--r-- | variable.c | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 56e6ac67eb..228e9a4913 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -287,6 +287,9 @@ class TestShapes < Test::Unit::TestCase tc = TooComplex.new tc.instance_variable_set(:@a, 1) tc.instance_variable_set(:@b, 2) + + tc.remove_instance_variable(:@a) + assert_nil(tc.instance_variable_get(:@a)) end; end diff --git a/variable.c b/variable.c index a374756974..1e44775887 100644 --- a/variable.c +++ b/variable.c @@ -2217,7 +2217,15 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name) break; } default: { - rb_shape_transition_shape_remove_ivar(obj, id, shape, &val); + if (rb_shape_obj_too_complex(obj)) { + struct gen_ivtbl *ivtbl; + if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) { + st_delete(ivtbl->as.complex.table, (st_data_t *)&id, (st_data_t *)&val); + } + } + else { + rb_shape_transition_shape_remove_ivar(obj, id, shape, &val); + } break; } } |