Commit 0d48a978 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'bouk-empty-ternary'

parents d77b2541 0b4017fd
...@@ -1362,6 +1362,10 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1362,6 +1362,10 @@ codegen(codegen_scope *s, node *tree, int val)
int pos1, pos2; int pos1, pos2;
node *e = tree->cdr->cdr->car; node *e = tree->cdr->cdr->car;
if (!tree->car) {
codegen(s, e, val);
return;
}
switch ((intptr_t)tree->car->car) { switch ((intptr_t)tree->car->car) {
case NODE_TRUE: case NODE_TRUE:
case NODE_INT: case NODE_INT:
......
...@@ -9,3 +9,7 @@ assert('peephole optimization does not eliminate move whose result is reused') d ...@@ -9,3 +9,7 @@ assert('peephole optimization does not eliminate move whose result is reused') d
method(&a &&= 0) method(&a &&= 0)
end end
end end
assert('empty condition in ternary expression parses correctly') do
assert_equal(() ? 1 : 2, 2)
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