Permalink
Browse files

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`
```
  • Loading branch information...
matz committed Feb 11, 2017
1 parent ff03a9a commit 1f2d786e3220ecb6b3ff95e31f538ce338374c54
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/vm.c
View
@@ -1652,7 +1652,7 @@ mrb_vm_exec(mrb_state *mrb, struct RProc *proc, mrb_code *pc)
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)) {

0 comments on commit 1f2d786

Please sign in to comment.