Merge pull request #3290 from bouk/unsafe-peep

Fix unsafe peephole optimization
This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-11-25 08:00:33 +09:00
committed by GitHub
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -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 {
+11
View File
@@ -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