aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--test/ruby/test_super.rb15
-rw-r--r--vm_insnhelper.c5
3 files changed, 27 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f293481f87..7457abdef8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 846f40946d..b518aa2914 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -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
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index c8cbaa07bf..8694f524f6 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -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);