ruby-changes:40663
From: nagachika <ko1@a...>
Date: Wed, 25 Nov 2015 01:03:03 +0900 (JST)
Subject: [ruby-changes:40663] nagachika:r52742 (ruby_2_2): merge revision(s) 52461: [Backport #11663]
nagachika 2015-11-25 01:02:52 +0900 (Wed, 25 Nov 2015) New Revision: 52742 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52742 Log: merge revision(s) 52461: [Backport #11663] * parse.y (kwd_append): fix segv after invalid keyword argument, preceding keyword list is NULL when syntax error is there. [ruby-core:71356] [Bug #11663] 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/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 52741) +++ ruby_2_2/ChangeLog (revision 52742) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Wed Nov 25 00:54:15 2015 Nobuyoshi Nakada <nobu@r...> + + * parse.y (kwd_append): fix segv after invalid keyword argument, + preceding keyword list is NULL when syntax error is there. + [ruby-core:71356] [Bug #11663] + Wed Nov 25 00:47:07 2015 SHIBATA Hiroshi <hsbt@r...> * lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained Index: ruby_2_2/parse.y =================================================================== --- ruby_2_2/parse.y (revision 52741) +++ ruby_2_2/parse.y (revision 52742) @@ -456,6 +456,8 @@ static NODE *new_attr_op_assign_gen(stru https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L456 static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs); #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs)) +static NODE *kwd_append(NODE*, NODE*); + static NODE *new_hash_gen(struct parser_params *parser, NODE *hash); #define new_hash(hash) new_hash_gen(parser, (hash)) @@ -4786,13 +4788,7 @@ f_block_kwarg : f_block_kw https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L4788 | f_block_kwarg ',' f_block_kw { /*%%%*/ - NODE *kws = $1; - - while (kws->nd_next) { - kws = kws->nd_next; - } - kws->nd_next = $3; - $$ = $1; + $$ = kwd_append($1, $3); /*% $$ = rb_ary_push($1, $3); %*/ @@ -4811,13 +4807,7 @@ f_kwarg : f_kw https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L4807 | f_kwarg ',' f_kw { /*%%%*/ - NODE *kws = $1; - - while (kws->nd_next) { - kws = kws->nd_next; - } - kws->nd_next = $3; - $$ = $1; + $$ = kwd_append($1, $3); /*% $$ = rb_ary_push($1, $3); %*/ @@ -6790,6 +6780,9 @@ formal_argument_gen(struct parser_params https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L6780 case ID_CLASS: yyerror("formal argument cannot be a class variable"); return 0; + default: + yyerror("formal argument must be local variable"); + return 0; #else default: lhs = dispatch1(param_error, lhs); @@ -8957,6 +8950,19 @@ gettable_gen(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L8950 compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id)); return 0; } + +static NODE * +kwd_append(NODE *kwlist, NODE *kw) +{ + if (kwlist) { + NODE *kws = kwlist; + while (kws->nd_next) { + kws = kws->nd_next; + } + kws->nd_next = kw; + } + return kwlist; +} #else /* !RIPPER */ static int id_is_var_gen(struct parser_params *parser, ID id) Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 52741) +++ ruby_2_2/version.h (revision 52742) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.4" #define RUBY_RELEASE_DATE "2015-11-25" -#define RUBY_PATCHLEVEL 198 +#define RUBY_PATCHLEVEL 199 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 Index: ruby_2_2/test/ruby/test_syntax.rb =================================================================== --- ruby_2_2/test/ruby/test_syntax.rb (revision 52741) +++ ruby_2_2/test/ruby/test_syntax.rb (revision 52742) @@ -184,6 +184,16 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_syntax.rb#L184 end end + def test_keyword_invalid_name + bug11663 = '[ruby-core:71356] [Bug #11663]' + + o = Object.new + assert_syntax_error('def o.foo(arg1?:) end', /arg1\?/, bug11663) + assert_syntax_error('def o.foo(arg1?:, arg2:) end', /arg1\?/, bug11663) + assert_syntax_error('proc {|arg1?:|}', /arg1\?/, bug11663) + assert_syntax_error('proc {|arg1?:, arg2:|}', /arg1\?/, bug11663) + end + def test_optional_self_reference bug9593 = '[ruby-core:61299] [Bug #9593]' o = Object.new Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r52461 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/