diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-18 10:31:28 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-18 10:31:28 +0900 |
| commit | ca2d47c20f91dc0ceec72052c28717bb0d7a74ef (patch) | |
| tree | 807a212e030f00135141b255b10a317458d610ed /src/vm.c | |
| parent | 47add060cc9e7b8492b5fda0dd712bcd2d7f0d32 (diff) | |
| download | mruby-ca2d47c20f91dc0ceec72052c28717bb0d7a74ef.tar.gz mruby-ca2d47c20f91dc0ceec72052c28717bb0d7a74ef.zip | |
Fix `super` from aliased methods to work correctly; fix #4718
We needed to preserve the original method name somewhere. We kept it in
the `env` structure pointed from aliased methods. #1457 and #1531 tried
to address this issue. But this patch is more memory efficient.
Limitation: this fix does not support `super` from methods defined by
`define_method`. This limitation may be addressed in the future, but
it's low priority.
Diffstat (limited to 'src/vm.c')
| -rw-r--r-- | src/vm.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1558,9 +1558,13 @@ RETRY_TRY_BLOCK: struct RClass *cls; mrb_callinfo *ci = mrb->c->ci; mrb_value recv, blk; + struct RProc *p = ci->proc; mrb_sym mid = ci->mid; - struct RClass* target_class = MRB_PROC_TARGET_CLASS(ci->proc); + struct RClass* target_class = MRB_PROC_TARGET_CLASS(p); + if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { /* alias support */ + mid = p->e.env->mid; /* restore old mid */ + } mrb_assert(bidx < irep->nregs); if (mid == 0 || !target_class) { @@ -2020,7 +2024,7 @@ RETRY_TRY_BLOCK: if (MRB_PROC_ENV_P(dst)) { struct REnv *e = MRB_PROC_ENV(dst); - if (!MRB_ENV_STACK_SHARED_P(e) || e->cxt != mrb->c) { + if (!MRB_ENV_STACK_SHARED_P(e) || (e->cxt && e->cxt != mrb->c)) { localjump_error(mrb, LOCALJUMP_ERROR_RETURN); goto L_RAISE; } |
