ruby-changes:41761
From: nobu <ko1@a...>
Date: Mon, 15 Feb 2016 15:44:16 +0900 (JST)
Subject: [ruby-changes:41761] nobu:r53835 (trunk): parse.y: kwarg to method with same name variable
nobu 2016-02-15 15:44:36 +0900 (Mon, 15 Feb 2016) New Revision: 53835 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53835 Log: parse.y: kwarg to method with same name variable * 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 files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_syntax.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53834) +++ ChangeLog (revision 53835) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Feb 15 15:44: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] + Mon Feb 15 14:43:28 2016 Martin Duerst <duerst@i...> * enc/unicode/case-folding.rb: Added debugging option Index: test/ruby/test_syntax.rb =================================================================== --- test/ruby/test_syntax.rb (revision 53834) +++ test/ruby/test_syntax.rb (revision 53835) @@ -360,6 +360,13 @@ WARN https://github.com/ruby/ruby/blob/trunk/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: parse.y =================================================================== --- parse.y (revision 53834) +++ parse.y (revision 53835) @@ -8073,7 +8073,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/parse.y#L8073 ident = tokenize_ident(parser, last_state); if (!IS_lex_state_for(last_state, EXPR_DOT|EXPR_FNAME) && lvar_defined(ident)) { - SET_LEX_STATE(EXPR_END); + SET_LEX_STATE(EXPR_END|EXPR_LABEL); } return result; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/