From: shugo@... Date: 2017-11-28T08:33:00+00:00 Subject: [ruby-core:83917] [Ruby trunk Bug#14068] Unused refinement breaks method search Issue #14068 has been updated by shugo (Shugo Maeda). The following patch seems to fix the problem: ``` diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 3c08a74..9a2f3cb 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2314,7 +2314,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st cc->me = refined_method_callable_without_refinement(cc->me); } else { - VALUE klass = RCLASS_SUPER(cc->me->owner); + VALUE klass = RCLASS_SUPER(cc->me->defined_class); cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL; } return vm_call_method(ec, cfp, calling, ci, cc); ``` ---------------------------------------- Bug #14068: Unused refinement breaks method search https://bugs.ruby-lang.org/issues/14068#change-67970 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: 2.5 * ruby -v: ruby 2.5.0dev (2017-10-30 trunk 60565) [x86_64-linux] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- The following is an expected behavior. ~~~ module M1 def foo p "M1#foo" end end module M2 end include M1 include M2 foo() #=> "M1#foo" ~~~ But, defining UnusedRefinement that refines M2, breaks the behavior, even if it is entirely not used. ~~~ module M1 def foo p "M1#foo" end end module M2 end module UnusedRefinement # <=== INSERTED refine(M2) do def foo p "M2#foo" end end end include M1 include M2 foo() #=> test.rb:20:in `
': undefined method `foo' for main:Object (NoMethodError) ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: