Project

General

Profile

Actions

Bug #11035

closed

Calling #hash method: inconsistency between dynamic and static symbols

Added by ko1 (Koichi Sasada) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
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.

Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

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

Applied in changeset r50182.


hash.c: compare symbols by identities

Actions #2

Updated by usa (Usaku NAKAMURA) almost 9 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) almost 9 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0