Skip to content

Commit

Permalink
Fix unexpected behavior with break
Browse files Browse the repository at this point in the history
```
def yie
  yield
end

def bre
  yie {
    1+1
    break
  }
end

p bre #=> display 2, but should be nil
```
  • Loading branch information
ksss committed Sep 26, 2016
1 parent 7a382e8 commit b1fa180
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mrbgems/mruby-compiler/core/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2852,6 +2852,9 @@ loop_break(codegen_scope *s, node *tree)
loop->pc3 = tmp;
}
else {
if (!tree) {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_BREAK));
}
}
Expand Down

0 comments on commit b1fa180

Please sign in to comment.