ruby-changes:47294
From: nagachika <ko1@a...>
Date: Sun, 23 Jul 2017 17:59:14 +0900 (JST)
Subject: [ruby-changes:47294] nagachika:r59409 (ruby_2_4): merge revision(s) 58641: [Backport #13547]
nagachika 2017-07-23 17:59:07 +0900 (Sun, 23 Jul 2017) New Revision: 59409 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59409 Log: merge revision(s) 58641: [Backport #13547] parse.y: brace after literal arg * parse.y (symbol, dsym, parser_set_number_literal, parser_yylex): 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] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/parse.y branches/ruby_2_4/test/ruby/test_syntax.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59408) +++ ruby_2_4/version.h (revision 59409) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-07-23" -#define RUBY_PATCHLEVEL 160 +#define RUBY_PATCHLEVEL 161 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 7 Index: ruby_2_4/parse.y =================================================================== --- ruby_2_4/parse.y (revision 59408) +++ ruby_2_4/parse.y (revision 59409) @@ -4254,7 +4254,7 @@ string_dvar : tGVAR https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L4254 symbol : tSYMBEG sym { - SET_LEX_STATE(EXPR_ENDARG); + SET_LEX_STATE(EXPR_END|EXPR_ENDARG); /*%%%*/ $$ = $2; /*% @@ -4271,7 +4271,7 @@ sym : fname https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L4271 dsym : tSYMBEG xstring_contents tSTRING_END { - SET_LEX_STATE(EXPR_ENDARG); + SET_LEX_STATE(EXPR_END|EXPR_ENDARG); /*%%%*/ $$ = dsym_node($2); /*% @@ -6659,7 +6659,7 @@ parser_set_number_literal(struct parser_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6659 type = tIMAGINARY; } set_yylval_literal(v); - SET_LEX_STATE(EXPR_ENDARG); + SET_LEX_STATE(EXPR_END|EXPR_ENDARG); return type; } @@ -8017,9 +8017,11 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L8017 } } if (token == tSTRING_END || token == tREGEXP_END || token == tLABEL_END) { + const enum lex_state_e next_state = + token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_END|EXPR_ENDARG; rb_gc_force_recycle((VALUE)lex_strterm); lex_strterm = 0; - SET_LEX_STATE(token == tLABEL_END ? EXPR_BEG|EXPR_LABEL : EXPR_ENDARG); + SET_LEX_STATE(next_state); } } return token; Index: ruby_2_4/test/ruby/test_syntax.rb =================================================================== --- ruby_2_4/test/ruby/test_syntax.rb (revision 59408) +++ ruby_2_4/test/ruby/test_syntax.rb (revision 59409) @@ -952,6 +952,16 @@ eom https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_syntax.rb#L952 assert_equal(:ok, result) end + def test_brace_after_literal_argument + bug = '[ruby-core:81037] [Bug #13547]' + error = /unexpected '{'/ + assert_syntax_error('m "x" {}', error) + assert_syntax_error('m 1 {}', error, bug) + assert_syntax_error('m 1.0 {}', error, bug) + assert_syntax_error('m :m {}', error, bug) + assert_syntax_error('m :"#{m}" {}', error, bug) + end + def test_return_toplevel feature4840 = '[ruby-core:36785] [Feature #4840]' code = "#{<<~"begin;"}\n#{<<~"end;"}" Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59408) +++ ruby_2_4 (revision 59409) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58641 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/