summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-12-23 10:43:47 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-12-23 11:14:12 +0900
commitca0f32a208052e485f02c803ce5ea249b0f7e554 (patch)
treea3fda034028ebde0224b711fc20d082098622a80 /src/vm.c
parentaa8786f79cfdf1cc424939bf6390323566e09030 (diff)
downloadmruby-ca0f32a208052e485f02c803ce5ea249b0f7e554.tar.gz
mruby-ca0f32a208052e485f02c803ce5ea249b0f7e554.zip
`super` should raise `TypeError` when the receiver is switched; fix #3911
The receiver can be switched using `#instance_eval` etc.
Diffstat (limited to 'src/vm.c')
-rw-r--r--src/vm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vm.c b/src/vm.c
index 1b92746cd..084811499 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1606,6 +1606,12 @@ RETRY_TRY_BLOCK:
}
}
recv = regs[0];
+ if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {
+ mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR,
+ "self has wrong type to call super in this context");
+ mrb_exc_set(mrb, exc);
+ goto L_RAISE;
+ }
blk = regs[bidx];
if (!mrb_nil_p(blk) && mrb_type(blk) != MRB_TT_PROC) {
blk = mrb_convert_type(mrb, blk, MRB_TT_PROC, "Proc", "to_proc");