Project

General

Profile

Actions

Bug #12855

closed

Inconsistent keys identity in compare_by_identity Hash when using literals

Added by Eregon (Benoit Daloze) over 7 years ago. Updated about 7 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[ruby-core:77684]

Description

This seems a regression since 2.2.
I would guess it's due to some optimization for having a string literal between []=.
That optimization should not trigger for compare_by_identity hashes, so both cases below are consistent.

h = {}.compare_by_identity
h['pear'] = 1
h['pear'] = 2

p h.size # => 1
p h


h = {}.compare_by_identity
k1 = 'pear'
h[k1] = 1
k2 = 'pear'
h[k2] = 2

p h.size # => 2
p h

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #9382: [patch] add opt_aref_str and opt_aset_strClosedtmm1 (Aman Karmani)01/08/2014Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0