From 7d6965f88d6abf0e1e9f92a58139dc56b27db07a Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 26 Jul 2017 00:56:44 +0000 Subject: parse.y: brace after array literal arg * parse.y (parser_yylex): array is another literal. set state to END too not only ENDARG and after a literal, so that a left brace after it should be a primary block bound to the literal, which causes syntax error. [ruby-core:81037] [Bug #13547] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 2 +- test/ruby/test_syntax.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 44a0bb6785..02d9412a2c 100644 --- a/parse.y +++ b/parse.y @@ -8374,7 +8374,7 @@ parser_yylex(struct parser_params *parser) if (c == ')') SET_LEX_STATE(EXPR_ENDFN); else - SET_LEX_STATE(EXPR_ENDARG); + SET_LEX_STATE(EXPR_END); if (c == '}') { if (!brace_nest--) c = tSTRING_DEND; } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index bd93285ac4..e2b5e0146e 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -974,6 +974,10 @@ eom assert_syntax_error('m 1.0 {}', error, bug) assert_syntax_error('m :m {}', error, bug) assert_syntax_error('m :"#{m}" {}', error, bug) + assert_syntax_error('m ?x {}', error, bug) + assert_syntax_error('m %[] {}', error, bug) + assert_syntax_error('m 0..1 {}', error, bug) + assert_syntax_error('m [] {}', error, bug) end def test_return_toplevel -- cgit v1.2.3