From 81f257aa10cce69cf2bee38f955f7c22c18e93e1 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 16 Jan 2015 05:21:00 +0000 Subject: [PATCH] merge revision(s) 49088: [Backport #10685] * vm_args.c (keyword_hash_p): fix non-symbol keys hash. rb_extract_keywords() returns 0 not Qnil when no symbol keys is included. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_keyword.rb | 7 +++++++ version.h | 2 +- vm_args.c | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ee0d1f0e5..4f90047e73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 16 14:20:52 2015 Nobuyoshi Nakada + + * vm_args.c (keyword_hash_p): fix non-symbol keys hash. + rb_extract_keywords() returns 0 not Qnil when no symbol keys is + included. + Fri Jan 16 11:06:17 2015 SHIBATA Hiroshi * lib/unicode_normalize.rb: typo fix. [ci skip] diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 82d6407fe3..70cdba1db2 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -559,4 +559,11 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal({:bar => "bar"}, obj.foo, bug10659) } end + + def m(a) yield a end + + def test_nonsymbol_key + result = m(["a" => 10]) { |a = nil, **b| [a, b] } + assert_equal([{"a" => 10}, {}], result) + end end diff --git a/version.h b/version.h index eebf6aae32..6dceadbe69 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-01-16" -#define RUBY_PATCHLEVEL 9 +#define RUBY_PATCHLEVEL 10 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 diff --git a/vm_args.c b/vm_args.c index 55f6a3417c..48a46d5619 100644 --- a/vm_args.c +++ b/vm_args.c @@ -179,7 +179,9 @@ keyword_hash_p(VALUE *kw_hash_ptr, VALUE *rest_hash_ptr, rb_thread_t *th, const th->mark_stack_len = msl; if (!NIL_P(*rest_hash_ptr)) { - *kw_hash_ptr = rb_extract_keywords(rest_hash_ptr); + VALUE hash = rb_extract_keywords(rest_hash_ptr); + if (!hash) hash = Qnil; + *kw_hash_ptr = hash; return TRUE; } else {