From 1f2d786e3220ecb6b3ff95e31f538ce338374c54 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 11 Feb 2017 21:21:19 +0900 Subject: Avoid direct return from ecall(); fix #3441 There's incompatibility left for mruby. When you return from `ensure` clause, mruby simply ignores the return value. CRuby returns from the method squashing the exception raised. ``` def f no_such_method() # NoMethodError ensure return 22 end p f() # CRuby prints `22` ``` --- src/vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/vm.c b/src/vm.c index 276e2ab6d..70583864e 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1652,7 +1652,7 @@ RETRY_TRY_BLOCK: switch (GETARG_B(i)) { case OP_R_RETURN: /* Fall through to OP_R_NORMAL otherwise */ - if (proc->env && !MRB_PROC_STRICT_P(proc)) { + if (ci->acc >=0 && proc->env && !MRB_PROC_STRICT_P(proc)) { struct REnv *e = top_env(mrb, proc); if (!MRB_ENV_STACK_SHARED_P(e)) { -- cgit v1.2.3