aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 17:12:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-09 17:12:43 +0000
commita6b3ad36dec0c52b4cb9619da15fb55b9feb209c (patch)
treef9d382e3c07f93d4318f2e87ecb6dbd1282d6a0e
parent6849ea75beea46113ef2d5846085bd75b7d79754 (diff)
downloadruby-a6b3ad36dec0c52b4cb9619da15fb55b9feb209c.tar.gz
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
-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 4de9844987..3b9f8f03fa 100644
--- a/parse.y
+++ b/parse.y
@@ -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;
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 640fbb9b64..00ba5192a1 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -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