From: brandon.j.fish@...
Date: 2017-11-05T19:36:06+00:00
Subject: [ruby-core:83681] [Ruby trunk Bug#14083] Refinement in block	calling incorrect method

Issue #14083 has been reported by bjfish (Brandon Fish).

----------------------------------------
Bug #14083: Refinement in block calling incorrect method
https://bugs.ruby-lang.org/issues/14083

* Author: bjfish (Brandon Fish)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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:

~~~ ruby
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

~~~ text
Example#test
Example#test in M1
Example#test in M1
Example#test in M2
~~~

Expected output

~~~ text
Example#test
Example#test in M1
Example#test
Example#test in M2
~~~






-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>