From: "k0kubun (Takashi Kokubun) via ruby-core" Date: 2024-05-28T23:43:10+00:00 Subject: [ruby-core:118051] [Ruby master Bug#20307] `Hash#update` from compare_by_identity hash can have unfrozen string keys Issue #20307 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE ruby_3_3 commit:917f3e5d22b3364002eb1fdc2f94b35ff76f6a73 merged revision(s) commit:f36a71e26995b69ff72bc132bbcf40ad89571414. ---------------------------------------- Bug #20307: `Hash#update` from compare_by_identity hash can have unfrozen string keys https://bugs.ruby-lang.org/issues/20307#change-108474 * Author: nobu (Nobuyoshi Nakada) * Status: Closed * Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: DONE ---------------------------------------- I don't think this behavior is expected. ```ruby i = Hash.new.compare_by_identity k = "a" i[k] = 0 h = {}.update(i) p h.compare_by_identity? # => false p h["a"] # => 0 k.upcase! # `k` is still in `h`. p h.keys.include?(k) # => true # but not found. p((h.fetch(k) rescue $!)) # => # h["A"] = 1 p h # => {"A"=>0, "A"=>1} ``` I expect `h` to still have `"a"=>0` entry. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/