From f3e5f2cd758f5013685d997ffd9efdcceccd449f Mon Sep 17 00:00:00 2001 From: ko1 Date: Sun, 28 Oct 2012 00:03:20 +0000 Subject: * bignum.c (bignew_1): Bignum instances are frozen. Feature #3222 * include/ruby/ruby.h: Fixnum instances are also frozen. * class.c (singleton_class_of): check Bignum before singleton cheking. * test/ruby/test_bignum.rb: add a test. * test/ruby/test_fixnum.rb: ditto. * test/ruby/marshaltestlib.rb, test/ruby/test_eval.rb, test/ruby/test_object.rb: catch up above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- class.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'class.c') diff --git a/class.c b/class.c index c5f0390853..e083bf633d 100644 --- a/class.c +++ b/class.c @@ -1323,8 +1323,10 @@ singleton_class_of(VALUE obj) return klass; } else { - if (BUILTIN_TYPE(obj) == T_FLOAT) + enum ruby_value_type type = BUILTIN_TYPE(obj); + if (type == T_FLOAT || type == T_BIGNUM) { rb_raise(rb_eTypeError, "can't define singleton"); + } } if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) && -- cgit v1.2.3