The `clone` method should copy object status (e.g. frozen) too; #4030

parent 7ed164ba
......@@ -348,6 +348,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)p->c);
clone = mrb_obj_value(p);
init_copy(mrb, clone, self);
p->flags = mrb_obj_ptr(self)->flags;
return clone;
}
......
......@@ -171,6 +171,10 @@ assert('Kernel#clone', '15.3.1.3.8') do
assert_true a.respond_to?(:test)
assert_false b.respond_to?(:test)
assert_true c.respond_to?(:test)
a.freeze
d = a.clone
assert_true d.frozen?
end
assert('Kernel#dup', '15.3.1.3.9') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment