diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-25 09:23:47 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-25 09:23:47 +0900 |
| commit | 0b4017fd6918005475ace8f46d5279e18ef49eb6 (patch) | |
| tree | 1697f3afde842fd206bb1a1d15fdcbde45029bff | |
| parent | d77b25410880f0c79bd215c406ec44a9dac07769 (diff) | |
| parent | 71641bbf732ab8cbadf8a07e20b2a939b0e3b82b (diff) | |
| download | mruby-0b4017fd6918005475ace8f46d5279e18ef49eb6.tar.gz mruby-0b4017fd6918005475ace8f46d5279e18ef49eb6.zip | |
resolve conflict; ref #3286
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 4 | ||||
| -rw-r--r-- | test/t/codegen.rb | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 39d62348a..5f42bf08d 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -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: diff --git a/test/t/codegen.rb b/test/t/codegen.rb index f910d37fb..cb2e75f93 100644 --- a/test/t/codegen.rb +++ b/test/t/codegen.rb @@ -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 |
