diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-23 08:15:57 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-07-23 08:15:57 +0000 |
commit | 524e628fd33511e37d8c9de0bb43e9ea2e68376c (patch) | |
tree | f382c2e28bd089ef49b07e179c2a3e40c0b58f35 | |
parent | 66163b7749fa4eb9e3e085dcfaac9df4715bc1f2 (diff) |
merge revision(s) 58638,58640: [Backport #11873]
test_syntax.rb: test_brace_after_local_variable
* test/ruby/test_syntax.rb (test_brace_after_local_variable):
another test using braces. [Bug #11873]
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/branches/ruby_2_4@59406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 13 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 15 insertions, 2 deletions
@@ -8019,7 +8019,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 e4f73b97cf..7742dd239a 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 @@ -939,6 +943,15 @@ eom assert_equal(:ok, result) end + def test_brace_after_local_variable + obj = Object.new + def obj.m; yield; end + result = assert_nothing_raised(SyntaxError) do + obj.instance_eval("m = 1; m {:ok}") + end + assert_equal(:ok, result) + end + def test_return_toplevel feature4840 = '[ruby-core:36785] [Feature #4840]' code = "#{<<~"begin;"}\n#{<<~"end;"}" @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-07-23" -#define RUBY_PATCHLEVEL 157 +#define RUBY_PATCHLEVEL 158 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 7 |