From 70dc199fdde6a70205410e0a8cfe4aff4c50344f Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 28 Sep 2002 02:41:05 +0000 Subject: [PATCH] * hash.c (rb_hash_become): Hash#become should check added self-assignment. * class.c (rb_make_metaclass): metaclass of a superclass may be NULL at boot time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ class.c | 7 ++++++- hash.c | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3bacde4257..a4b08b8d25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Sep 28 10:40:44 2002 Yukihiro Matsumoto + + * hash.c (rb_hash_become): Hash#become should check added + self-assignment. + + * class.c (rb_make_metaclass): metaclass of a superclass may be + NULL at boot time. + Sat Sep 28 09:50:03 2002 KONISHI Hiromasa * ext/extmk.rb: The condition judgment without necessity was deleted. diff --git a/class.c b/class.c index d55c37e991..316118bfe3 100644 --- a/class.c +++ b/class.c @@ -152,7 +152,12 @@ rb_make_metaclass(obj, super) RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass; } else { - RBASIC(klass)->klass = RBASIC(rb_class_real(super))->klass; + VALUE metasuper = RBASIC(rb_class_real(super))->klass; + + /* metaclass of a superclass may be NULL at boot time */ + if (metasuper) { + RBASIC(klass)->klass; + } } return klass; diff --git a/hash.c b/hash.c index 3c0aeab2b8..6e1c247ba4 100644 --- a/hash.c +++ b/hash.c @@ -575,6 +575,7 @@ static VALUE rb_hash_become(hash, hash2) VALUE hash, hash2; { + if (hash == hash2) return hash; hash2 = to_hash(hash2); rb_hash_clear(hash); st_foreach(RHASH(hash2)->tbl, replace_i, hash);