summaryrefslogtreecommitdiff
path: root/shape.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-11-24 14:31:36 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-11-25 09:32:36 -0500
commit564ef66e26454079188f024eb28e48a4ef1b2085 (patch)
treedb61d8fcffc416c42c54cc6b583888177002809f /shape.c
parentf6b292b5ca8b397b00cc4e82d8ae7ede8b09f25f (diff)
Verify that duplicate shape is not created
This adds an assertion that the instance variable does not already exist in the shape tree when creating a new shape.
Diffstat (limited to 'shape.c')
-rw-r--r--shape.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/shape.c b/shape.c
index 6d6235dd3d..96cd2750af 100644
--- a/shape.c
+++ b/shape.c
@@ -654,13 +654,20 @@ rb_shape_get_next_iv_shape(rb_shape_t* shape, ID id)
}
rb_shape_t *
-rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id)
+rb_shape_get_next(rb_shape_t *shape, VALUE obj, ID id)
{
RUBY_ASSERT(!is_instance_id(id) || RTEST(rb_sym2str(ID2SYM(id))));
if (UNLIKELY(shape->type == SHAPE_OBJ_TOO_COMPLEX)) {
return shape;
}
+#if RUBY_DEBUG
+ attr_index_t index;
+ if (rb_shape_get_iv_index(shape, id, &index)) {
+ rb_bug("rb_shape_get_next: trying to create ivar that already exists at index %u", index);
+ }
+#endif
+
bool allow_new_shape = true;
if (BUILTIN_TYPE(obj) == T_OBJECT) {