summaryrefslogtreecommitdiff
path: root/shape.c
diff options
context:
space:
mode:
authorHaldun Bayhantopcu <haldun@github.com>2023-02-15 21:13:54 +0100
committerAaron Patterson <aaron.patterson@gmail.com>2023-02-15 15:43:46 -0800
commit0b4b2cd1ee161f2875375181e0978d7757e25c8a (patch)
treef071ac7815fcc526c3698b9aa5954f8b7d2b54be /shape.c
parent70d84a5f3deab5caaeb88134e9d90b1dca4a0462 (diff)
downloadruby-0b4b2cd1ee161f2875375181e0978d7757e25c8a.tar.gz
Fix removing ivars from clases and modules.
Co-authored-by: Adam Hess <hparker@github.com>
Diffstat (limited to 'shape.c')
-rw-r--r--shape.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/shape.c b/shape.c
index 7c3bdf8c50..6852a8d554 100644
--- a/shape.c
+++ b/shape.c
@@ -238,7 +238,9 @@ remove_shape_recursive(VALUE obj, ID id, rb_shape_t * shape, VALUE * removed)
// has the same attributes as this shape.
if (new_parent) {
bool dont_care;
- rb_shape_t * new_child = get_next_shape_internal(new_parent, shape->edge_name, shape->type, &dont_care, true, false);
+ enum ruby_value_type type = BUILTIN_TYPE(obj);
+ bool new_shape_necessary = type == T_CLASS || type == T_MODULE;
+ rb_shape_t * new_child = get_next_shape_internal(new_parent, shape->edge_name, shape->type, &dont_care, true, new_shape_necessary);
new_child->capacity = shape->capacity;
if (new_child->type == SHAPE_IVAR) {
move_iv(obj, id, shape->next_iv_index - 1, new_child->next_iv_index - 1);