Project

General

Profile

Bug #11035

Calling #hash method: inconsistency between dynamic and static symbols

Added by ko1 (Koichi Sasada) over 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:<unknown>]

Description

There is an inconsistency between static symbols and dynamic symbols.

class Symbol
  def hash
    raise
  end
end

h = {}
h[:foo] = 1          #=> no problem
h['bar'.to_sym] = 2  #=> unhandled exception

I think it should be same behavior.
My favorite is skip calling #hash for all Symbol objects.

Associated revisions

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]

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

merge revision(s) 50182,50183: [Backport #11035]

    * hash.c (rb_any_hash): Symbols are compared by the identities
      always.  [ruby-core:68767] [Bug #11035]

    * test/ruby/test_symbol.rb: fix syntax error.

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

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

merge revision(s) 50182,50183: [Backport #11035]

* hash.c (rb_any_hash): Symbols are compared by the identities
  always.  [ruby-core:68767] [Bug #11035]

* test/ruby/test_symbol.rb: fix syntax error.

History

#1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

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

Applied in changeset r50182.


hash.c: compare symbols by identities

  • hash.c (rb_any_hash): Symbols are compared by the identities always. [ruby-core:68767] [Bug #11035]
#2

Updated by usa (Usaku NAKAMURA) over 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) about 4 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

Backported into ruby_2_2 branch at rr50620.

Also available in: Atom PDF