Issue #12514 has been updated by Shugo Maeda.


Tiago Cardoso wrote:
> potatoe is not a variable, but a method call. The method is defined right after. That should be the whole point of it, right?

The potatoe is defined in Extension, but String is only refined in the scope where using is called or the block of refine.
The definition of Extensions#vegetables is out of either scope, and thus the method call of potatoe fails.


----------------------------------------
Bug #12514: Refinements: when including Module as refinement, can't call other module methods
https://bugs.ruby-lang.org/issues/12514#change-59373

* Author: Tiago Cardoso
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Very simple script which reproduces the problem:

<pre>
module Extensions
  def vegetables ; potatoe ; end
  def potatoe ; "potatoe" ; end
end

module Refinary
  refine String do
    # this doesn't work
    include Extensions
    # this would work...
    # def vegetables ; potatoe ; end
    # def potatoe ; "potatoe" ; end
  end
end

using Refinary

puts "tomatoe".vegetables

#=> in `<main>': undefined method `vegetables' for "tomatoe":String 
</pre>

failing from ruby 2.0 to 2.3



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