aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-26 00:56:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-26 00:56:44 +0000
commit7d6965f88d6abf0e1e9f92a58139dc56b27db07a (patch)
treecd35ad367588e1712e76fac1ab304f4412962bee
parentc6c975ca4ed009e568ace27394f96f0e112616e6 (diff)
downloadruby-7d6965f88d6abf0e1e9f92a58139dc56b27db07a.tar.gz
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
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_syntax.rb4
2 files changed, 5 insertions, 1 deletions
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