Forum: Ruby-dev [ruby-trunk - Bug #7261][Open] Symbol#to_proc to retrieve a method from current refinement

0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 matz (Yukihiro Matsumoto) (Guest)
on 2012-11-01 21:53
(Received via mailing list)
Issue #7261 has been reported by matz (Yukihiro Matsumoto).

----------------------------------------
Bug #7261: Symbol#to_proc to retrieve a method from current refinement
https://bugs.ruby-lang.org/issues/7261

Author: matz (Yukihiro Matsumoto)
Status: Open
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-01 trunk 37415) [i486-linux]


Currently Symbol#to_proc retrieves the global definition of the method,
since refinement is a lexical scope.
But if possible, it is better that Symbol#to_proc can retrieve a method
from current refinement.

  module Silly
    refine Integer do
      def bar; p :bar; end
    end
  end

  module Stupid
    using Silly
    1.bar # => :bar
    [1,2].each(&:bar) # => undefined method `bar'
  end

What do you think?

It should be done before 2.0.0 if we merge, to avoid future
compatibility issues.

Matz.
This topic is locked and can not be replied to.