1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_args.c: fix non-symbol keys hash

* 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/trunk@49088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-01 00:14:23 +00:00
parent 1026907467
commit 6a37b8cde3
3 changed files with 16 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Thu Jan 1 09:14:21 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 <akr@fsij.org>
* lib/resolv.rb (Resolv::DNS::Label::Str#initialize): Set encoding

View file

@ -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

View file

@ -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 {