Fix frozen object inspect
In the rails/rails CI build for Ruby master we found that some tests were failing due to inspect on a frozen object being incorrect. An object's instance variable count was incorrect when frozen causing the object's inspect to not splat out the object. This fixes the issue and adds a test for inspecting frozen objects. Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com> Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
parent
a44040c9e4
commit
0ab0229c11
Notes:
git
2022-10-01 05:58:22 +09:00
3
shape.c
3
shape.c
@ -149,13 +149,12 @@ get_next_shape_internal(rb_shape_t* shape, ID id, VALUE obj, enum shape_type sha
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAPE_IVAR_UNDEF:
|
case SHAPE_IVAR_UNDEF:
|
||||||
|
case SHAPE_FROZEN:
|
||||||
new_shape->iv_count = new_shape->parent->iv_count;
|
new_shape->iv_count = new_shape->parent->iv_count;
|
||||||
break;
|
break;
|
||||||
case SHAPE_ROOT:
|
case SHAPE_ROOT:
|
||||||
rb_bug("Unreachable");
|
rb_bug("Unreachable");
|
||||||
break;
|
break;
|
||||||
case SHAPE_FROZEN:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_id_table_insert(shape->edges, id, (VALUE)new_shape);
|
rb_id_table_insert(shape->edges, id, (VALUE)new_shape);
|
||||||
|
@ -993,4 +993,13 @@ class TestObject < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_frozen_inspect
|
||||||
|
obj = Object.new
|
||||||
|
obj.instance_variable_set(:@a, "a")
|
||||||
|
ins = obj.inspect
|
||||||
|
obj.freeze
|
||||||
|
|
||||||
|
assert_equal(ins, obj.inspect)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user