`Kernel#clone` and `Kernel#dup` no longer raise `TypeError`; fix
In ISO, those methods should raise `TypeError`, but the spec has been
changed.  The change was discussed in [Feature#12979].
MODIFY
src/kernel.c
src/kernel.c
@@ -325,7 +325,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
mrb_value clone;
if (mrb_immediate_p(self)) {
- mrb_raisef(mrb, E_TYPE_ERROR, "can't clone %v", self);
+ return self;
}
if (mrb_sclass_p(self)) {
mrb_raise(mrb, E_TYPE_ERROR, "can't clone singleton class");
@@ -366,7 +366,7 @@ mrb_obj_dup(mrb_state *mrb, mrb_value obj)
mrb_value dup;
if (mrb_immediate_p(obj)) {
- mrb_raisef(mrb, E_TYPE_ERROR, "can't dup %v", obj);
+ return obj;
}
if (mrb_sclass_p(obj)) {
mrb_raise(mrb, E_TYPE_ERROR, "can't dup singleton class");

MODIFY
test/t/kernel.rb
test/t/kernel.rb
@@ -197,17 +197,6 @@ assert('Kernel#dup', '15.3.1.3.9') do
a.set(2)
c = a.dup
- immutables = [ 1, :foo, true, false, nil ]
- error_count = 0
- immutables.each do |i|
- begin
- i.dup
- rescue TypeError
- error_count += 1
- end
- end
-
- assert_equal immutables.size, error_count
assert_equal 2, a.get
assert_equal 1, b.get
assert_equal 2, c.get

`Kernel#clone` and `Kernel#dup` no longer raise `TypeError`; fix #4974

In ISO, those methods should raise `TypeError`, but the spec has been
changed.  The change was discussed in [Feature#12979].