Project

General

Profile

Bug #12178

Enumerable#inject(:+) doesn't respect redefined Fixnum#+

Added by usa (Usaku NAKAMURA) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-dev:49510]

Description

r54120以降、Fixnum#+ を再定義している場合(する奴はいないとは思うものの)、inject(:+) の中で再定義後のメソッドが呼ばれなくなります。

C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(:+)"
ruby 2.4.0dev (2016-03-15 trunk 54118) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
15

C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(:+)"
ruby 2.4.0dev (2016-03-15 trunk 54120) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
9

C:\> ruby -ve "class Fixnum; def +(o); self*o; end; end; p [1,3,5].inject(&:+)"
ruby 2.4.0dev (2016-03-15 trunk 54120) [x64-mswin64_100]
-e:1: warning: method redefined; discarding old +
15

History

Updated by akr (Akira Tanaka) over 3 years ago

  • Status changed from Open to Closed

Fixed at r54122

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONTNEED

Also available in: Atom PDF