summaryrefslogtreecommitdiff
path: root/shape.c
diff options
context:
space:
mode:
authorMax Bernstein <rubybugs@bernsteinbear.com>2025-08-18 15:58:38 -0700
committerGitHub <noreply@github.com>2025-08-18 18:58:38 -0400
commit306d50811dd060d876d1eb364a0d5e6106f5e4f1 (patch)
treee46e6f0c15ad826c9d3c8d3551f7b26da75a0f1a /shape.c
parent6f472c8b61bf8bbf4c2fd3c0af9ddaf92538c94e (diff)
Don't allow looking at the shape ID of immediates (#14266)
It only makes sense for heap objects.
Diffstat (limited to 'shape.c')
-rw-r--r--shape.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/shape.c b/shape.c
index b10b52d76f..d58f9f1d0c 100644
--- a/shape.c
+++ b/shape.c
@@ -369,7 +369,7 @@ RUBY_FUNC_EXPORTED shape_id_t
rb_obj_shape_id(VALUE obj)
{
if (RB_SPECIAL_CONST_P(obj)) {
- return SPECIAL_CONST_SHAPE_ID;
+ rb_bug("rb_obj_shape_id: called on a special constant");
}
if (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE) {
@@ -1425,6 +1425,9 @@ rb_shape_parent(VALUE self)
static VALUE
rb_shape_debug_shape(VALUE self, VALUE obj)
{
+ if (RB_SPECIAL_CONST_P(obj)) {
+ rb_raise(rb_eArgError, "Can't get shape of special constant");
+ }
return shape_id_t_to_rb_cShape(rb_obj_shape_id(obj));
}