ruby-changes:37221
From: naruse <ko1@a...>
Date: Sat, 17 Jan 2015 22:25:38 +0900 (JST)
Subject: [ruby-changes:37221] naruse:r49302 (ruby_2_2): merge revision(s) 49193: [Backport #10719]
naruse 2015-01-17 22:25:14 +0900 (Sat, 17 Jan 2015) New Revision: 49302 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49302 Log: merge revision(s) 49193: [Backport #10719] * parse.y (assocs, assoc): eliminate splatting empty literal hashes. [ruby-core:67446] [Bug #10719] * compile.c (compile_array_): supprt splatted hash in hash type. Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/compile.c 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 49301) +++ ruby_2_2/ChangeLog (revision 49302) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sat Jan 17 17:56:45 2015 Nobuyoshi Nakada <nobu@r...> + + * parse.y (assocs, assoc): eliminate splatting empty literal + hashes. [ruby-core:67446] [Bug #10719] + + * compile.c (compile_array_): supprt splatted hash in hash type. + Sat Jan 17 16:49:49 2015 Nobuyoshi Nakada <nobu@r...> * ext/readline/readline.c (readline_s_refresh_line): initialize Index: ruby_2_2/compile.c =================================================================== --- ruby_2_2/compile.c (revision 49301) +++ ruby_2_2/compile.c (revision 49302) @@ -2467,11 +2467,14 @@ compile_array_(rb_iseq_t *iseq, LINK_ANC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/compile.c#L2467 rb_bug("compile_array: This node is not NODE_ARRAY, but %s", ruby_node_name(nd_type(node))); } - if (type == COMPILE_ARRAY_TYPE_HASH && !node->nd_head) { - opt_p = 0; + if (type != COMPILE_ARRAY_TYPE_ARRAY && !node->nd_head) { kw = node->nd_next; - node = kw->nd_next; - kw = kw->nd_head; + node = 0; + if (kw) { + opt_p = 0; + node = kw->nd_next; + kw = kw->nd_head; + } break; } if (opt_p && nd_type(node->nd_head) != NODE_LIT) { Index: ruby_2_2/parse.y =================================================================== --- ruby_2_2/parse.y (revision 49301) +++ ruby_2_2/parse.y (revision 49302) @@ -2396,7 +2396,7 @@ aref_args : none https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2396 | args ',' assocs trailer { /*%%%*/ - $$ = arg_append($1, new_hash($3)); + $$ = $3 ? arg_append($1, new_hash($3)) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2404,7 +2404,7 @@ aref_args : none https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2404 | assocs trailer { /*%%%*/ - $$ = NEW_LIST(new_hash($1)); + $$ = $1 ? NEW_LIST(new_hash($1)) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2434,7 +2434,7 @@ opt_call_args : none https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2434 | args ',' assocs ',' { /*%%%*/ - $$ = arg_append($1, new_hash($3)); + $$ = $3 ? arg_append($1, new_hash($3)) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2442,7 +2442,7 @@ opt_call_args : none https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2442 | assocs ',' { /*%%%*/ - $$ = NEW_LIST(new_hash($1)); + $$ = $1 ? NEW_LIST(new_hash($1)) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2469,7 +2469,7 @@ call_args : command https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2469 | assocs opt_block_arg { /*%%%*/ - $$ = NEW_LIST(new_hash($1)); + $$ = NEW_LIST($1 ? new_hash($1) : 0); $$ = arg_blk_pass($$, $2); /*% $$ = arg_add_assocs(arg_new(), $1); @@ -2479,7 +2479,7 @@ call_args : command https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L2479 | args ',' assocs opt_block_arg { /*%%%*/ - $$ = arg_append($1, new_hash($3)); + $$ = $3 ? arg_append($1, new_hash($3)) : $1; $$ = arg_blk_pass($$, $4); /*% $$ = arg_add_optblock(arg_add_assocs($1, $3), $4); @@ -5030,13 +5030,19 @@ assocs : assoc https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L5030 /*%%%*/ NODE *assocs = $1; NODE *tail = $3; - if (assocs->nd_head && - !tail->nd_head && nd_type(tail->nd_next) == NODE_ARRAY && - nd_type(tail->nd_next->nd_head) == NODE_HASH) { - /* DSTAR */ - tail = tail->nd_next->nd_head->nd_head; + if (!assocs) { + assocs = tail; } - $$ = list_concat(assocs, tail); + else if (tail) { + if (assocs->nd_head && + !tail->nd_head && nd_type(tail->nd_next) == NODE_ARRAY && + nd_type(tail->nd_next->nd_head) == NODE_HASH) { + /* DSTAR */ + tail = tail->nd_next->nd_head->nd_head; + } + assocs = list_concat(assocs, tail); + } + $$ = assocs; /*% $$ = rb_ary_push($1, $3); %*/ @@ -5074,7 +5080,11 @@ assoc : arg_value tASSOC arg_value https://github.com/ruby/ruby/blob/trunk/ruby_2_2/parse.y#L5080 | tDSTAR arg_value { /*%%%*/ - $$ = list_append(NEW_LIST(0), $2); + if (nd_type($2) == NODE_HASH && + !($2->nd_head && $2->nd_head->nd_alen)) + $$ = 0; + else + $$ = list_append(NEW_LIST(0), $2); /*% $$ = dispatch1(assoc_splat, $2); %*/ Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 49301) +++ ruby_2_2/version.h (revision 49302) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-01-17" -#define RUBY_PATCHLEVEL 22 +#define RUBY_PATCHLEVEL 23 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 Index: ruby_2_2/test/ruby/test_syntax.rb =================================================================== --- ruby_2_2/test/ruby/test_syntax.rb (revision 49301) +++ ruby_2_2/test/ruby/test_syntax.rb (revision 49302) @@ -136,6 +136,13 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_syntax.rb#L136 assert_equal([1, 2], a, bug10315) end + def test_keyword_empty_splat + assert_separately([], <<-'end;') + bug10719 = '[ruby-core:67446] [Bug #10719]' + assert_valid_syntax("foo(a: 1, **{})", bug10719) + end; + end + def test_keyword_self_reference bug9593 = '[ruby-core:61299] [Bug #9593]' o = Object.new Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r49193 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/