aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-29 15:14:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-29 15:14:05 +0000
commite1ddda73a9f556cda82467c865fcabb3188ba677 (patch)
treefe8fe44e5e154ae24ec4452e7a522adbb7eed4d0 /object.c
parent431bd9b8e881d375564c7660a6dcd78cd8dd6a12 (diff)
downloadruby-e1ddda73a9f556cda82467c865fcabb3188ba677.tar.gz
object.c: no TypeError at special const clone
* object.c (rb_obj_clone2): no longer raise a TypeError for special constants, and return itself instead. however, if freeze option is false, raise an ArgumentError. [Feature#12979] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/object.c b/object.c
index 7075e13683..a1dcf830e7 100644
--- a/object.c
+++ b/object.c
@@ -346,7 +346,9 @@ rb_obj_clone2(int argc, VALUE *argv, VALUE obj)
}
if (rb_special_const_p(obj)) {
- rb_raise(rb_eTypeError, "can't clone %s", rb_obj_classname(obj));
+ if (kwfreeze == Qfalse)
+ rb_raise(rb_eArgError, "can't unfreeze %s", rb_obj_classname(obj));
+ return obj;
}
clone = rb_obj_alloc(rb_obj_class(obj));
RBASIC(clone)->flags &= (FL_TAINT|FL_PROMOTED0|FL_PROMOTED1);