[ruby-core:76124] [Ruby trunk Bug#12514][Rejected] Refinements: when including Module as refinement, can't call other module methods
From:
shugo@...
Date:
2016-06-24 05:41:32 UTC
List:
ruby-core #76124
Issue #12514 has been updated by Shugo Maeda.
Status changed from Open to Rejected
> #=> in <main>': undefined methodvegetables' for "tomatoe":String
On my box, the following exception is raised instead:
```
t.rb:2:in `vegetables': undefined local variable or method `potatoe' for "tomatoe":String (NameError)
from t.rb:18:in `<main>'
```
And this is an expected behavior because String is not refined in the definition of `Extensions`.
----------------------------------------
Bug #12514: Refinements: when including Module as refinement, can't call other module methods
https://bugs.ruby-lang.org/issues/12514#change-59328
* 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>