diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/ruby/test_keyword.rb | 7 | ||||
-rw-r--r-- | vm_args.c | 4 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Thu Jan 1 09:14:21 2015 Nobuyoshi Nakada <[email protected]> + + * vm_args.c (keyword_hash_p): fix non-symbol keys hash. + rb_extract_keywords() returns 0 not Qnil when no symbol keys is + included. + Wed Dec 31 17:48:43 2014 Tanaka Akira <[email protected]> * lib/resolv.rb (Resolv::DNS::Label::Str#initialize): Set encoding 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 @@ -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 { |