Commit 32bacb21 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #570 from skandhas/pr-remove-redundant-LOOP_NORMAL-checkups

remove redundant LOOP_NORMAL checkups in function:codegen. and fix #561
parents 276b7702 6c8d2ca3
...@@ -1501,7 +1501,7 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1501,7 +1501,7 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_RETURN: case NODE_RETURN:
codegen(s, tree, VAL); codegen(s, tree, VAL);
pop(); pop();
if (s->loop && s->loop->type != LOOP_NORMAL) { if (s->loop) {
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN)); genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN));
} }
else { else {
......
...@@ -389,7 +389,7 @@ assert('BS Block [ruby-core:14395]') do ...@@ -389,7 +389,7 @@ assert('BS Block [ruby-core:14395]') do
t.test_for_bug t.test_for_bug
end end
assert("BS Block 32") do assert("BS Block 33") do
module TestReturnFromNestedBlock module TestReturnFromNestedBlock
def self.test def self.test
1.times do 1.times do
...@@ -402,3 +402,31 @@ assert("BS Block 32") do ...@@ -402,3 +402,31 @@ assert("BS Block 32") do
end end
TestReturnFromNestedBlock.test == :ok TestReturnFromNestedBlock.test == :ok
end end
assert("BS Block 34") do
module TestReturnFromNestedBlock_BSBlock34
def self.test
1.times do
while true
return :ok
end
end
:bad
end
end
TestReturnFromNestedBlock_BSBlock34.test == :ok
end
assert("BS Block 35") do
module TestReturnFromNestedBlock_BSBlock35
def self.test
1.times do
until false
return :ok
end
end
:bad
end
end
TestReturnFromNestedBlock_BSBlock35.test == :ok
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment