From 0f2f021330bf3b00d504f3dce2c24c267f3eee72 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 2 Jun 2017 12:06:40 +0900 Subject: Fixed a bug in `void_expr_error`. --- mrbgems/mruby-compiler/core/parse.y | 8 ++-- test/t/codegen.rb | 75 ------------------------------------- 2 files changed, 5 insertions(+), 78 deletions(-) delete mode 100644 test/t/codegen.rb diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index eb348afa2..2c1a943be 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -3474,10 +3474,12 @@ void_expr_error(parser_state *p, node *n) void_expr_error(p, n->cdr->cdr); break; case NODE_BEGIN: - while (n->cdr) { - n = n->cdr; + if (n->cdr) { + while (n->cdr) { + n = n->cdr; + } + void_expr_error(p, n->car); } - void_expr_error(p, n->car); break; default: break; diff --git a/test/t/codegen.rb b/test/t/codegen.rb deleted file mode 100644 index 29f5ad525..000000000 --- a/test/t/codegen.rb +++ /dev/null @@ -1,75 +0,0 @@ -## -# Codegen tests - -assert('peephole optimization does not eliminate move whose result is reused') do - assert_raise LocalJumpError do - def method - yield - end - method(&a &&= 0) - end -end - -assert('empty condition in ternary expression parses correctly') do - assert_equal(() ? 1 : 2, 2) -end - -assert('method call with exactly 127 arguments') do - def args_to_ary(*args) - args - end - - assert_equal [0]*127, args_to_ary( - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - ) -end - -assert('nested empty heredoc') do - _, a = nil, <