From: beaurain.florent@... Date: 2020-05-26T09:45:24+00:00 Subject: [ruby-core:98523] [Ruby master Bug#16914] Hash.new with a block returns a proc sometimes Issue #16914 has been reported by beauraF (Florent Beaurain). ---------------------------------------- Bug #16914: Hash.new with a block returns a proc sometimes https://bugs.ruby-lang.org/issues/16914 * Author: beauraF (Florent Beaurain) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Hello, First of all, I want to apologize because this bug report will not be realized at all in good shape. I encounter this problem on a rails application currently in production, but I am unable to reproduce it. I failed to provide you a script to reproduce. I'm very sorry. But.. maybe it will ring a bell to someone. --- So, I have a hash, built this way: ```ruby messages .each_with_object(Hash.new { [] }) { ... } .transform_values { ... } { [:appointment, {:import_identifier=>"TVER111111114^ORBIS"}]=>#, [:appointment, {:import_identifier=>"TVER111111115^ORBIS"}]=>#, [:appointment, {:import_identifier=>"TVER111111116^ORBIS"}]=>#, [:appointment, {:id=>"30"}]=>#, [:appointment, {:import_identifier=>"TVER111111111^ORBIS"}]=>#, [:appointment, {:import_identifier=>"TVER111111112^ORBIS"}]=>#, } ``` Here is the result in `ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]` when I try to access it: ```ruby hash[[:appointment, {:import_identifier=>"TVER111111114^ORBIS"}]] => # hash[[:appointment, {:import_identifier=>"TVER111111117^ORBIS"}]] => nil ``` Here is the result in `ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]` when I try to access it: ```ruby hash[[:appointment, {:import_identifier=>"TVER111111114^ORBIS"}]] => # hash[[:appointment, {:import_identifier=>"TVER111111117^ORBIS"}]] => # hash[[:appointment, {:import_identifier=>"TVER111111117^ORBIS"}]].call => [] ``` note: `retry_inbound_messages.rb:75` => `.each_with_object(Hash.new { [] }) { ... }` --- So, if I'm right, the result on ruby 2.6, was not the good one but acceptable one on my side. On ruby 2.7, we're close to the good result, but we have to call the proc manually, which causes a lot of worries on my side. At your entire disposal, if I can help in any way. -- https://bugs.ruby-lang.org/ Unsubscribe: