Project

General

Profile

Actions

Bug #14083

closed

Refinement in block calling incorrect method

Added by bjfish (Brandon Fish) about 7 years ago. Updated over 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:83681]
Tags:

Description

Tested on ruby versions 2.3.4 and 2.4.1

When a refinement is used inside a block, the scope of the refinement is not ending when the block has ended. The following example illustrates the issue:

Example:

class Example
  def test
    puts "Example#test"
  end
end

module M1
  refine Example do
    def test
      puts "Example#test in M1"
    end
  end
end

module M2
  refine Example do
    def test
      puts "Example#test in M2"
    end
  end
end

e = Example.new
[M1, M2].each { |r| 
  e.test
  using r
  e.test 
}

Actual Output

Example#test
Example#test in M1
Example#test in M1
Example#test in M2

Expected output

Example#test
Example#test in M1
Example#test
Example#test in M2

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #11704: Refinements only get "used" once in loopRejectedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Bug #18572: Performance regression when invoking refined methodsClosedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0