vm_insnhelper.c: missing super in method module

* vm_insnhelper.c (vm_search_super_method): direct superclass of a
  module is found when super called in a Method object generated a
  method defined in a module, call method_missing in that case.
  [ruby-core:59358] [Bug #9315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-28 23:21:14 +00:00
parent e521a19aa4
commit 24c3331bdf
3 changed files with 27 additions and 0 deletions

View File

@ -1,3 +1,10 @@
Sun Dec 29 08:21:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_search_super_method): direct superclass of a
module is found when super called in a Method object generated a
method defined in a module, call method_missing in that case.
[ruby-core:59358] [Bug #9315]
Sun Dec 29 07:27:51 2013 Benoit Daloze <eregontp@gmail.com>
* compar.c (cmp_eq_recursive): Fix the return value, the value for

View File

@ -407,4 +407,19 @@ class TestSuper < Test::Unit::TestCase
assert_equal([false, false], y.foo(false, false))
assert_equal([1, 2, 3, false, 5], y.foo(1, 2, 3, false, 5))
end
def test_missing_super_in_method_module
bug9315 = '[ruby-core:59358] [Bug #9315]'
a = Module.new do
def foo
super
end
end
b = Class.new do
include a
end
assert_raise(NoMethodError, bug9315) do
b.new.method(:foo).call
end
end
end

View File

@ -2024,6 +2024,11 @@ vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_inf
" by define_method() is not supported."
" Specify all arguments explicitly.");
}
if (!ci->klass) {
ci->aux.missing_reason = NOEX_SUPER;
CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
return;
}
/* TODO: use inline cache */
ci->me = rb_method_entry(ci->klass, ci->mid, &ci->defined_class);