Commit 68f60714 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2729 from kou/fix-if-and-no-value-returned-case

Fix a bug that if and no return value case can't return true clause value
parents d0bc006a 584d6de3
......@@ -1462,8 +1462,13 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_AB(OP_MOVE, cursp(), pos));
push();
}
else if (pos3) {
dispatch_linked(s, pos3);
else {
if (pos3) {
dispatch_linked(s, pos3);
}
if (head) {
pop();
}
}
}
break;
......
......@@ -241,6 +241,20 @@ assert('Return values of case statements') do
assert_equal 1, fb.call
end
assert('Return values of if and case statements') do
true_clause_value =
if true
1
else
case 2
when 3
end
4
end
assert_equal 1, true_clause_value
end
assert('splat in case statement') do
values = [3,5,1,7,8]
testa = [1,2,7]
......
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