[前][次][番号順一覧][スレッド一覧]

ruby-changes:58252

From: Nobuyoshi <ko1@a...>
Date: Tue, 15 Oct 2019 19:41:38 +0900 (JST)
Subject: [ruby-changes:58252] f94202fcc2 (master): Use compare_by_identity hash [Bug #16250]

https://git.ruby-lang.org/ruby.git/commit/?id=f94202fcc2

From f94202fcc228d0348ca050a7b18a8f8a538a7305 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 15 Oct 2019 09:54:23 +0900
Subject: Use compare_by_identity hash [Bug #16250]


diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index fbcb0bd..0198838 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -70,7 +70,7 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L70
         $stdout.tty? && supported? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
       end
 
-      def inspect_colorable?(obj, seen: {})
+      def inspect_colorable?(obj, seen: {}.compare_by_identity)
         case obj
         when String, Symbol, Regexp, Integer, Float, FalseClass, TrueClass, NilClass
           true
@@ -137,8 +137,8 @@ module IRB # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/irb/color.rb#L137
       private
 
       def without_circular_ref(obj, seen:, &block)
-        return false if seen.key?(obj.object_id)
-        seen[obj.object_id] = true
+        return false if seen.key?(obj)
+        seen[obj] = true
         block.call
       ensure
         seen.delete(obj.object_id)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]