summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 708c207dc..418e1f371 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -276,8 +276,11 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
case OP_RETURN:
return 0;
case OP_MOVE:
- s->iseq[s->pc-1] = MKOP_AB(OP_RETURN, GETARG_B(i0), OP_R_NORMAL);
- return 0;
+ if (GETARG_A(i0) >= s->nlocals) {
+ s->iseq[s->pc-1] = MKOP_AB(OP_RETURN, GETARG_B(i0), OP_R_NORMAL);
+ return 0;
+ }
+ break;
case OP_SETIV:
case OP_SETCV:
case OP_SETCONST: