ruby-changes:46519
From: nobu <ko1@a...>
Date: Wed, 10 May 2017 02:12:49 +0900 (JST)
Subject: [ruby-changes:46519] nobu:r58640 (trunk): parse.y: do after cmdarg in paren
nobu 2017-05-10 02:12:43 +0900 (Wed, 10 May 2017) New Revision: 58640 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58640 Log: 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] Modified files: trunk/parse.y trunk/test/ruby/test_syntax.rb Index: parse.y =================================================================== --- parse.y (revision 58639) +++ parse.y (revision 58640) @@ -7886,7 +7886,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L7886 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; Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 58639) +++ test/ruby/test_syntax.rb (revision 58640) @@ -898,6 +898,10 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L898 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/