Fix removing non-existent ivar for too complex
This commit is contained in:
parent
a1e24ab484
commit
9c6dd25093
@ -265,8 +265,13 @@ class TestShapes < Test::Unit::TestCase
|
|||||||
c = Class.new
|
c = Class.new
|
||||||
c.instance_variable_set(:@a, 1)
|
c.instance_variable_set(:@a, 1)
|
||||||
assert_equal(1, c.instance_variable_get(:@a))
|
assert_equal(1, c.instance_variable_get(:@a))
|
||||||
|
|
||||||
c.remove_instance_variable(:@a)
|
c.remove_instance_variable(:@a)
|
||||||
assert_nil(c.instance_variable_get(:@a))
|
assert_nil(c.instance_variable_get(:@a))
|
||||||
|
|
||||||
|
assert_raise(NameError) do
|
||||||
|
c.remove_instance_variable(:@a)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -290,6 +295,10 @@ class TestShapes < Test::Unit::TestCase
|
|||||||
|
|
||||||
tc.remove_instance_variable(:@a)
|
tc.remove_instance_variable(:@a)
|
||||||
assert_nil(tc.instance_variable_get(:@a))
|
assert_nil(tc.instance_variable_get(:@a))
|
||||||
|
|
||||||
|
assert_raise(NameError) do
|
||||||
|
tc.remove_instance_variable(:@a)
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2199,7 +2199,9 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name)
|
|||||||
case T_MODULE:
|
case T_MODULE:
|
||||||
IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(id);
|
IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(id);
|
||||||
if (rb_shape_obj_too_complex(obj)) {
|
if (rb_shape_obj_too_complex(obj)) {
|
||||||
st_delete(RCLASS_IV_HASH(obj), (st_data_t *)&id, (st_data_t *)&val);
|
if (!st_delete(RCLASS_IV_HASH(obj), (st_data_t *)&id, (st_data_t *)&val)) {
|
||||||
|
val = Qundef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_shape_transition_shape_remove_ivar(obj, id, shape, &val);
|
rb_shape_transition_shape_remove_ivar(obj, id, shape, &val);
|
||||||
@ -2220,7 +2222,9 @@ rb_obj_remove_instance_variable(VALUE obj, VALUE name)
|
|||||||
if (rb_shape_obj_too_complex(obj)) {
|
if (rb_shape_obj_too_complex(obj)) {
|
||||||
struct gen_ivtbl *ivtbl;
|
struct gen_ivtbl *ivtbl;
|
||||||
if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) {
|
if (rb_gen_ivtbl_get(obj, 0, &ivtbl)) {
|
||||||
st_delete(ivtbl->as.complex.table, (st_data_t *)&id, (st_data_t *)&val);
|
if (!st_delete(ivtbl->as.complex.table, (st_data_t *)&id, (st_data_t *)&val)) {
|
||||||
|
val = Qundef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user