ruby-changes:42544
From: nagachika <ko1@a...>
Date: Sun, 17 Apr 2016 03:46:28 +0900 (JST)
Subject: [ruby-changes:42544] nagachika:r54618 (ruby_2_3): merge revision(s) 53834, 53835, 53836: [Backport #12073]
nagachika 2016-04-17 04:43:02 +0900 (Sun, 17 Apr 2016) New Revision: 54618 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54618 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_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/parse.y branches/ruby_2_3/test/ruby/test_syntax.rb branches/ruby_2_3/version.h Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 54617) +++ ruby_2_3/version.h (revision 54618) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-04-17" -#define RUBY_PATCHLEVEL 84 +#define RUBY_PATCHLEVEL 85 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 4 Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 54617) +++ ruby_2_3/ChangeLog (revision 54618) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Sun Apr 17 04:30:13 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] + Sun Apr 17 04:20:40 2016 Nobuyoshi Nakada <nobu@r...> * eval.c (setup_exception): set the cause only if it is explicitly Index: ruby_2_3/test/ruby/test_syntax.rb =================================================================== --- ruby_2_3/test/ruby/test_syntax.rb (revision 54617) +++ ruby_2_3/test/ruby/test_syntax.rb (revision 54618) @@ -360,6 +360,13 @@ WARN https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_syntax.rb#L360 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_3/parse.y =================================================================== --- ruby_2_3/parse.y (revision 54617) +++ ruby_2_3/parse.y (revision 54618) @@ -7823,16 +7823,14 @@ tokadd_ident(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L7823 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)) { - SET_LEX_STATE(EXPR_END); - } + + return ident; } static int @@ -8003,6 +8001,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L8001 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; @@ -8102,7 +8101,12 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L8101 SET_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)) { + SET_LEX_STATE(EXPR_END|EXPR_LABEL); + } return result; } Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53834-53836 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/