Skip to content

Commit

Permalink
resolve conflict; ref #3286
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Nov 25, 2016
2 parents d77b254 + 71641bb commit 0b4017f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mrbgems/mruby-compiler/core/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions test/t/codegen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ def method
method(&a &&= 0)
end
end

assert('empty condition in ternary expression parses correctly') do
assert_equal(() ? 1 : 2, 2)
end

0 comments on commit 0b4017f

Please sign in to comment.