1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: do after cmdarg in paren

* parse.y (parser_yylex): set state to ENDARG after a string
  literal, so that `do` after a literal should be `do_block` and
  bound to the outer method, as well as a numeric/symbol literal.
  [ruby-core:72482] [Bug #11873]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-05-09 17:12:43 +00:00
parent 462e6675d2
commit 046c94380b
2 changed files with 5 additions and 1 deletions

View file

@ -7886,7 +7886,7 @@ parser_yylex(struct parser_params *parser)
if (token == tSTRING_END || token == tREGEXP_END || token == tLABEL_END) {
rb_gc_force_recycle((VALUE)lex_strterm);
lex_strterm = 0;
SET_LEX_STATE(token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_END);
SET_LEX_STATE(token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_ENDARG);
}
}
return token;

View file

@ -898,6 +898,10 @@ eom
assert_valid_syntax %q{a b(c d), 1 do end}, bug11873
assert_valid_syntax %q{a b{c(d)}, 1 do end}, bug11873
assert_valid_syntax %q{a b(c(d)), 1 do end}, bug11873
assert_valid_syntax %q{a b{c d}, "x" do end}, bug11873
assert_valid_syntax %q{a b(c d), "x" do end}, bug11873
assert_valid_syntax %q{a b{c(d)}, "x" do end}, bug11873
assert_valid_syntax %q{a b(c(d)), "x" do end}, bug11873
end
def test_block_after_cmdarg_in_paren