Project

General

Profile

Feature #11476

Methods defined in Refinements cannot be called via send

Added by matsuda (Akira Matsuda) almost 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:<unknown>]

Description

class C end

module M
  refine C do
    def a() p:hello end
    def b() p:world end
  end
end

using M

C.new.a
C.new.send :b
% ruby -v t.rb
ruby 2.3.0dev (2015-08-22 trunk 51660) [x86_64-darwin14]
:hello
t.rb:13:in `<main>': undefined method `b' for #<C:0x007f86c9a12af0> (NoMethodError)

Related issues

Has duplicate Ruby trunk - Feature #12079: Loosening the condition for refinementRejectedActions

Associated revisions

Revision c8fee08a
Added by nobu (Nobuyoshi Nakada) over 2 years ago

vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#send. [Feature #11476]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56450
Added by nobu (Nobuyoshi Nakada) over 2 years ago

vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56450
Added by nobu (Nobuyoshi Nakada) over 2 years ago

vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56450
Added by nobu (Nobuyoshi Nakada) over 2 years ago

vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56450
Added by nobu (Nobuyoshi Nakada) over 2 years ago

vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 81556803
Added by kazu over 2 years ago

NEWS mention refinements with Kernel#send and BasicObject#send. [Feature #11476]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 56451
Added by znz (Kazuhiro NISHIYAMA) over 2 years ago

NEWS mention refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56451
Added by kazu over 2 years ago

NEWS mention refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56451
Added by kazu over 2 years ago

NEWS mention refinements with Kernel#send and BasicObject#send. [Feature #11476]

Revision 56451
Added by kazu over 2 years ago

NEWS mention refinements with Kernel#send and BasicObject#send. [Feature #11476]

History

#1

Updated by shugo (Shugo Maeda) over 3 years ago

  • Tracker changed from Bug to Feature
  • Status changed from Open to Assigned
  • Assignee changed from shugo (Shugo Maeda) to matz (Yukihiro Matsumoto)

It's an intended behavior that Kernel#send ignores refinements as described at https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec

What do you think of it, Matz?

#2

Updated by matsuda (Akira Matsuda) over 3 years ago

Aah, I'm sorry that I missed that part of the documentation.
But indeed I felt the behaviour weird while using the feature in a real-world library.

Updated by matz (Yukihiro Matsumoto) over 2 years ago

Accepted.

The current behavior is according to the direct interpretation of the refinement spec. But many people expect send to be another form of a method call (including refinement). And now I agree with it.

Matz

#4

Updated by shugo (Shugo Maeda) over 2 years ago

  • Has duplicate Feature #12079: Loosening the condition for refinement added
#5

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Assigned to Closed

Applied in changeset r56450.


vm_insnhelper.c: refinements with send

  • vm_insnhelper.c (vm_call_opt_send): enable refinements with Kernel#send and BasicObject#__send__. [Feature #11476]

Also available in: Atom PDF