Project

General

Profile

Bug #8703

hash_type is not duplicated if hash is empty

Added by Glass_saga (Masaki Matsushita) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.1.0dev (2013-07-29 trunk 42224) [x86_64-linux]
[ruby-core:56256]

Description

{}.compare_by_identity.dup.compare_by_identity? #=> false
{1=>1}.compare_by_identity.dup.compare_by_identity? #=> true

I think it is a bug.

patch.diff (449 Bytes) patch.diff Glass_saga (Masaki Matsushita), 07/29/2013 04:30 PM

Associated revisions

Revision ac82a1b2
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 42227
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42227
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42227
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42227
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42227
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 1f7839f1
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 42229
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42229
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42229
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42229
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 42229
Added by nobu (Nobuyoshi Nakada) over 4 years ago

hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

Revision 4ccf22e1
Added by nagachika (Tomoyuki Chikanaga) about 4 years ago

merge revision(s) r42224,r42225,r42226,r42227,r42228,r42229,r42232: [Backport #8703]

* hash.c (rb_hash_assoc): performance improvement by replacing
  compare function in RHASH(hash)->ntbl->type temporarily.

* hash.c (rb_hash_assoc): aggregate object can be initialized only
  with link time constants.

* hash.c (rb_hash_initialize_copy): clear old table before copy new
  table.

* hash.c (rb_hash_initialize_copy): copy st_table type even if empty.
   [Bug #8703]

* hash.c (rb_hash_initialize_copy): copy st_table type even if empty.
   [Bug #8703]

* hash.c (rb_hash_initialize_copy): clear old table before copy new
  table.

* hash.c (rb_hash_assoc): aggregate object can be initialized only
  with link time constants.

* hash.c (rb_hash_assoc): revert r42224. table->type->compare is
  called only if hashes are matched.

* test/ruby/test_hash.rb: add a test to check using #== to compare.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1 Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42227.
Masaki, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


hash.c: copied identhash

  • hash.c (rb_hash_initialize_copy): copy st_table type even if empty. [Bug #8703]

#2 [ruby-core:60701] Updated by usa (Usaku NAKAMURA) about 4 years ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: REQUIRED

#3 [ruby-core:60766] Updated by nagachika (Tomoyuki Chikanaga) about 4 years ago

  • Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE

r42224, r42225, r42226, r42227, r42228, r42229 and r42232 were backported to ruby_2_0_0 at 44979.

Also available in: Atom PDF