Project

General

Profile

Actions

Bug #12738

closed

Array#flattenで特異クラスが引き継がれる

Added by ktsj (Kazuki Tsujimoto) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-08 master 56109) [x86_64-linux]
[ruby-dev:49781]

Description

Array#flattenで生成されたオブジェクトがflattenのレシーバと特異クラスを共有してしまっています。

a = []
class << a
  def m; :m; end
end
p a.flatten.m #=> :m
Actions #1

Updated by ktsj (Kazuki Tsujimoto) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r56111.


  • array.c (flatten): use rb_obj_class instead of rb_class_of
    because rb_class_of may return a singleton class.
    [ruby-dev:49781] [Bug #12738]

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: DONE

ruby_2_3 r56233 merged revision(s) 56111.

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: DONE to 2.1: UNKNOWN, 2.2: DONE, 2.3: DONE

ruby_2_2 r56305 merged revision(s) 56111.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0