Skip to content

Commit

Permalink
Fix codegen issue causing misaligned register
Browse files Browse the repository at this point in the history
  • Loading branch information
bouk committed Nov 24, 2016
1 parent a630c4f commit 1253982
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mrbgems/mruby-compiler/core/codegen.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2024,6 +2024,7 @@ codegen(codegen_scope *s, node *tree, int val)
} }
genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc)); genop(s, MKOP_sBx(OP_JMP, s->loop->pc2 - s->pc));
} }
if (val) push();
break; break;


case NODE_RETRY: case NODE_RETRY:
Expand Down Expand Up @@ -2058,6 +2059,7 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_sBx(OP_JMP, lp->pc1 - s->pc)); genop(s, MKOP_sBx(OP_JMP, lp->pc1 - s->pc));
} }
} }
if (val) push();
} }
break; break;


Expand Down
20 changes: 20 additions & 0 deletions test/t/codegen.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@
##
# Codegen tests

assert('codegen absorbs arguments to redo and retry if they are the argument of a call') do
assert_nothing_raised do
a=*"1", case nil
when 1
redo |
1
end
end

assert_nothing_raised do
a=*"1", case nil
when 1
retry |
1
end
end
end

0 comments on commit 1253982

Please sign in to comment.