summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-12-20 15:53:37 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-12-20 19:37:26 +0900
commit165e7b181b8a238aa546bd78b0baef1312e7000f (patch)
tree99e7b23363d7f1c3985da85402a79cb30d3888cd /src/vm.c
parentd0f60182af9114f6840d993d74f492e483302805 (diff)
downloadmruby-165e7b181b8a238aa546bd78b0baef1312e7000f.tar.gz
mruby-165e7b181b8a238aa546bd78b0baef1312e7000f.zip
Fixed method look-up for `method_missing` in OP_SUPER; ref #3905
Method look-up for `OP_SUPER` should start from the superclass of the `target_class` but if it fails, the look-up for `method_missing` should start from the class of the receiver. The following code explains the case: ```ruby class Bar def foo super end end class Foo<Bar def method_missing(mid, *) p mid end end ``` Foo.new.foo
Diffstat (limited to 'src/vm.c')
-rw-r--r--src/vm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/vm.c b/src/vm.c
index 885888985..bf33cce51 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1619,6 +1619,10 @@ RETRY_TRY_BLOCK:
m = mrb_method_search_vm(mrb, &c, mid);
if (MRB_METHOD_UNDEF_P(m)) {
mrb_sym missing = mrb_intern_lit(mrb, "method_missing");
+
+ if (mid != missing) {
+ c = mrb_class(mrb, recv);
+ }
m = mrb_method_search_vm(mrb, &c, missing);
if (MRB_METHOD_UNDEF_P(m)) {
mrb_value args = (argc < 0) ? regs[a+1] : mrb_ary_new_from_values(mrb, n, regs+a+1);