From b45d95fa9e825f10154207cf6411ea515b071c2b Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 12 Jun 2021 16:08:21 +0900 Subject: Raise `TypeError` with `super` inside `instance_eval` / `class_eval` Commit d0f60182af9114f6840d993d74f492e483302805 introduced an exception as a limitation of mruby. Subsequent CRuby-2.7 has changed its behavior to raise an exception. ref: https://github.com/ruby/ruby/commit/55b7ba368696033f2e89b77cbcd4a05dec97b139 --- src/vm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vm.c b/src/vm.c index ac4f05067..9eb667daa 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1725,13 +1725,12 @@ RETRY_TRY_BLOCK: else if (target_class->tt == MRB_TT_MODULE) { target_class = mrb_vm_ci_target_class(ci); if (target_class->tt != MRB_TT_ICLASS) { - mrb_value exc = mrb_exc_new_lit(mrb, E_RUNTIME_ERROR, "superclass info lost [mruby limitations]"); - mrb_exc_set(mrb, exc); - goto L_RAISE; + goto super_typeerror; } } recv = regs[0]; if (!mrb_obj_is_kind_of(mrb, recv, target_class)) { + super_typeerror: ; mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR, "self has wrong type to call super in this context"); mrb_exc_set(mrb, exc); -- cgit v1.2.3