Skip to content

Commit

Permalink
Transition frozen string to frozen root shape
Browse files Browse the repository at this point in the history
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
  • Loading branch information
jemmaissroff and tenderlove committed Oct 19, 2022
1 parent 5ca23ca commit 0aaa613
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 0 additions & 8 deletions shape.c
Expand Up @@ -203,14 +203,6 @@ rb_shape_transition_shape_frozen(VALUE obj)
rb_shape_t* next_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();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/optional/capi/shared/rbasic.rb
Expand Up @@ -10,7 +10,7 @@
obj, _ = @data.call
initial = @specs.get_flags(obj)
obj.freeze
@specs.get_flags(obj).should == @freeze | initial
(@specs.get_flags(obj) & 0xFFFF).should == (@freeze | initial) & 0xFFFF
end

it "supports setting the FREEZE flag" do
Expand Down
12 changes: 12 additions & 0 deletions test/ruby/test_string.rb
Expand Up @@ -887,6 +887,18 @@ def test_dup
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
verbose, $VERBOSE = $VERBOSE, nil

Expand Down

0 comments on commit 0aaa613

Please sign in to comment.