From: eregontp@... Date: 2016-12-22T12:45:37+00:00 Subject: [ruby-core:78805] [Ruby trunk Bug#12855] Inconsistent keys identity in compare_by_identity Hash when using literals Issue #12855 has been updated by Benoit Daloze. Eric Wong wrote: > Unintentional, yes, but maybe moot since frozen_string_literal > is going to be default in the future (maybe that case changed?) > > Anyways, I hate this patch because it makes insns.def bigger, > and insns.def is already too big IMHO: > > https://80x24.org/spew/20161222004752.4086-1-e@80x24.org/raw > > Somebody else can commit; I hate it too much. Thank you for the patch! I would like to commit it then, unless there is an objection. IMHO optimizations have to be correct, even in edge cases. Such instructions are already a trade-off of duplication and complexity for speed improvement, so this small change in size does not matter much to me. Optimizations need to be totally transparent to the user to be called as such. ---------------------------------------- Bug #12855: Inconsistent keys identity in compare_by_identity Hash when using literals https://bugs.ruby-lang.org/issues/12855#change-62212 * Author: Benoit Daloze * Status: Assigned * Priority: Normal * Assignee: Aman Gupta * Target version: * ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- 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. ~~~ruby 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 ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: