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

ruby-changes:57619

From: Jeremy <ko1@a...>
Date: Sat, 7 Sep 2019 06:30:49 +0900 (JST)
Subject: [ruby-changes:57619] 258843106f (master): Fix SortedSet subclasses that override initialize

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

From 258843106f343d05732499dd1832958eb1bf64f0 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Tue, 4 Jun 2019 19:08:54 -0700
Subject: Fix SortedSet subclasses that override initialize

The first time SortedSet#initialize is called, it overwrites
itself, then recalls #initialize, which results in calling the
subclass's initialize, not the current initialize.

Just inline the default initialize behavior to avoid this issue.

No test for this as it can only be triggered the very first time
that SortedSet#initialize is called.

Fixes [Bug #15830]

diff --git a/lib/set.rb b/lib/set.rb
index 921f18f..a0e945e 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -804,7 +804,8 @@ class SortedSet < Set https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L804
 
   def initialize(*args, &block) # :nodoc:
     SortedSet.setup
-    initialize(*args, &block)
+    @keys = nil
+    super
   end
 end
 
-- 
cgit v0.10.2


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

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