Project

General

Profile

Actions

Bug #12178

closed

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

Added by usa (Usaku NAKAMURA) about 8 years ago. Updated about 8 years ago.

Status:
Closed
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

Updated by akr (Akira Tanaka) about 8 years ago

  • Status changed from Open to Closed

Fixed at r54122

Updated by usa (Usaku NAKAMURA) about 8 years ago

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

Also available in: Atom PDF

Like0
Like0Like0