Merge branch 'bouk-empty-ternary'

This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-11-25 09:24:09 +09:00
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -1362,6 +1362,10 @@ codegen(codegen_scope *s, node *tree, int val)
int pos1, pos2;
node *e = tree->cdr->cdr->car;
if (!tree->car) {
codegen(s, e, val);
return;
}
switch ((intptr_t)tree->car->car) {
case NODE_TRUE:
case NODE_INT:
+4
View File
@@ -9,3 +9,7 @@ assert('peephole optimization does not eliminate move whose result is reused') d
method(&a &&= 0)
end
end
assert('empty condition in ternary expression parses correctly') do
assert_equal(() ? 1 : 2, 2)
end