ruby-changes:42602
From: usa <ko1@a...>
Date: Fri, 22 Apr 2016 13:54:38 +0900 (JST)
Subject: [ruby-changes:42602] usa:r54676 (ruby_2_2): merge revision(s) 53834, 53835, 53836: [Backport #12073]
usa 2016-04-22 14:51:15 +0900 (Fri, 22 Apr 2016) New Revision: 54676 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54676 Log: merge revision(s) 53834,53835,53836: [Backport #12073] parse.y: simplify local ID condition * parse.y (tokenize_ident, parse_ident): ident in tokenize_ident() can be a local id only when called from parse_ident(), but never from parse_gvar() and parse_atmark(). * parse.y (parse_ident): allow keyword arguments just after a method where the same name local variable is defined. [ruby-core:73816] [Bug#12073] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/parse.y branches/ruby_2_2/test/ruby/test_syntax.rb branches/ruby_2_2/version.h Index: ruby_2_2/test/ruby/test_syntax.rb =================================================================== --- ruby_2_2/test/ruby/test_syntax.rb (revision 54675) +++ ruby_2_2/test/ruby/test_syntax.rb (revision 54676) @@ -340,6 +340,13 @@ WARN https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_syntax.rb#L340 assert_valid_syntax("{label: <<-DOC\n""DOC\n""}", bug11849) end + def test_cmdarg_kwarg_lvar_clashing_method + bug12073 = '[ruby-core:73816] [Bug#12073]' + a = 1 + assert_valid_syntax("a b: 1") + assert_valid_syntax("a = 1; a b: 1", bug12073) + end + def test_duplicated_arg assert_syntax_error("def foo(a, a) end", /duplicated argument name/) assert_nothing_raised { def foo(_, _) end } Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 54675) +++ ruby_2_2/ChangeLog (revision 54676) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Fri Apr 22 14:48:09 2016 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parse_ident): allow keyword arguments just after a + method where the same name local variable is defined. + [ruby-core:73816] [Bug#12073] + Fri Apr 22 14:34:27 2016 Nobuyoshi Nakada <nobu@r...> * eval.c (setup_exception): set the cause only if it is explicitly Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 54675) +++ ruby_2_2/version.h (revision 54676) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.5" #define RUBY_RELEASE_DATE "2016-04-22" -#define RUBY_PATCHLEVEL 297 +#define RUBY_PATCHLEVEL 298 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 4 Index: ruby_2_2/parse.y =================================================================== --- ruby_2_2/parse.y (revision 54675) +++ ruby_2_2/parse.y (revision 54676) @@ -7589,16 +7589,14 @@ tokadd_ident(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L7589 return 0; } -static void +static ID tokenize_ident(struct parser_params *parser, const enum lex_state_e last_state) { ID ident = TOK_INTERN(); set_yylval_name(ident); - if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) && - is_local_id(ident) && lvar_defined(ident)) { - lex_state = EXPR_END; - } + + return ident; } static int @@ -7764,6 +7762,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L7762 int result = 0; int mb = ENC_CODERANGE_7BIT; const enum lex_state_e last_state = lex_state; + ID ident; do { if (!ISASCII(c)) mb = ENC_CODERANGE_UNKNOWN; @@ -7863,7 +7862,12 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L7862 lex_state = EXPR_END; } - tokenize_ident(parser, last_state); + ident = tokenize_ident(parser, last_state); + if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) && + (result == tIDENTIFIER) && /* not EXPR_FNAME, not attrasgn */ + lvar_defined(ident)) { + lex_state = EXPR_END|EXPR_LABEL; + } return result; } Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53834 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/