Permalink
Browse files

* hash.c (recursive_hash): hash value of emptied hash should be

  equal to an empty hash.  [ruby-core:38650]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 48fd404 commit 86bbfdadf3d9f2da5febeb02a3dcf81f3f2478ef @nobu nobu committed Aug 2, 2011
Showing with 9 additions and 0 deletions.
  1. +5 −0 ChangeLog
  2. +1 −0 hash.c
  3. +3 −0 test/ruby/test_hash.rb
View
@@ -1,3 +1,8 @@
+Tue Aug 2 12:03:16 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * hash.c (recursive_hash): hash value of emptied hash should be
+ equal to an empty hash. [ruby-core:38650]
+
Tue Aug 2 11:42:15 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (rb_enc_symname2_p): :! is valid symbol. [Bug #5136]
View
1 hash.c
@@ -1685,6 +1685,7 @@ recursive_hash(VALUE hash, VALUE dummy, int recur)
if (!RHASH(hash)->ntbl)
return LONG2FIX(0);
hval = RHASH(hash)->ntbl->num_entries;
+ if (!hval) return LONG2FIX(0);
if (recur)
hval = rb_hash_uint(rb_hash_start(rb_hash(rb_cHash)), hval);
else
View
@@ -809,6 +809,9 @@ def o.eql?(x); false; end
def test_hash2
assert_kind_of(Integer, {}.hash)
+ h = {1=>2}
+ h.shift
+ assert_equal({}.hash, h.hash, '[ruby-core:38650]')
end
def test_update2

0 comments on commit 86bbfda

Please sign in to comment.