Project

General

Profile

Bug #14083

Refinement in block calling incorrect method

Added by bjfish (Brandon Fish) almost 2 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:83681]

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

Also available in: Atom PDF