mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #3290 from bouk/unsafe-peep
Fix unsafe peephole optimization
This commit is contained in:
@@ -1798,8 +1798,10 @@ codegen(codegen_scope *s, node *tree, int val)
|
||||
int pos;
|
||||
|
||||
pop();
|
||||
if (val && vsp >= 0) {
|
||||
genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
|
||||
if (val) {
|
||||
if (vsp >= 0) {
|
||||
genop(s, MKOP_AB(OP_MOVE, vsp, cursp()));
|
||||
}
|
||||
pos = genop(s, MKOP_AsBx(name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), 0));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
##
|
||||
# Codegen tests
|
||||
|
||||
assert('peephole optimization does not eliminate move whose result is reused') do
|
||||
assert_raise LocalJumpError do
|
||||
def method
|
||||
yield
|
||||
end
|
||||
method(&a &&= 0)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user