Transition frozen string to frozen root shape
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
parent
5ca23caa20
commit
0aaa6133ed
Notes:
git
2022-10-19 18:06:40 +00:00
8
shape.c
8
shape.c
@ -203,14 +203,6 @@ rb_shape_transition_shape_frozen(VALUE obj)
|
|||||||
rb_shape_t* next_shape;
|
rb_shape_t* next_shape;
|
||||||
|
|
||||||
if (shape == rb_shape_get_root_shape()) {
|
if (shape == rb_shape_get_root_shape()) {
|
||||||
switch (BUILTIN_TYPE(obj)) {
|
|
||||||
case T_OBJECT:
|
|
||||||
case T_CLASS:
|
|
||||||
case T_MODULE:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
next_shape = rb_shape_get_frozen_root_shape();
|
next_shape = rb_shape_get_frozen_root_shape();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -10,7 +10,7 @@ describe :rbasic, shared: true do
|
|||||||
obj, _ = @data.call
|
obj, _ = @data.call
|
||||||
initial = @specs.get_flags(obj)
|
initial = @specs.get_flags(obj)
|
||||||
obj.freeze
|
obj.freeze
|
||||||
@specs.get_flags(obj).should == @freeze | initial
|
(@specs.get_flags(obj) & 0xFFFF).should == (@freeze | initial) & 0xFFFF
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports setting the FREEZE flag" do
|
it "supports setting the FREEZE flag" do
|
||||||
|
@ -887,6 +887,18 @@ CODE
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class StringWithIVSet < String
|
||||||
|
def set_iv
|
||||||
|
@foo = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ivar_set_after_frozen_dup
|
||||||
|
str = StringWithIVSet.new.freeze
|
||||||
|
str.dup.set_iv
|
||||||
|
assert_raise(FrozenError) { str.set_iv }
|
||||||
|
end
|
||||||
|
|
||||||
def test_each
|
def test_each
|
||||||
verbose, $VERBOSE = $VERBOSE, nil
|
verbose, $VERBOSE = $VERBOSE, nil
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user