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

Check type of empty keyword [Bug #16603]

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
This commit is contained in:
Seiei Miyagi 2020-02-03 17:43:03 +09:00 committed by Yusuke Endoh
parent a635c93fde
commit 11963da9e8
Notes: git 2020-02-03 17:55:08 +09:00
2 changed files with 7 additions and 1 deletions

View file

@ -4253,7 +4253,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popp
FLUSH_CHUNK();
const NODE *kw = node->nd_next->nd_head;
int empty_kw = nd_type(kw) == NODE_LIT; /* foo( ..., **{}, ...) */
int empty_kw = nd_type(kw) == NODE_LIT && RB_TYPE_P(kw->nd_lit, T_HASH); /* foo( ..., **{}, ...) */
int first_kw = first_chunk && stack_len == 0; /* foo(1,2,3, **kw, ...) */
int last_kw = !node->nd_next->nd_next; /* foo( ..., **kw) */
int only_kw = last_kw && first_kw; /* foo(1,2,3, **kw) */

View file

@ -4076,4 +4076,10 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase
mock.new.foo
end
end
def test_splat_fixnum
bug16603 = '[ruby-core:97047] [Bug #16603]'
assert_raise(TypeError, bug16603) { p(**42) }
assert_raise(TypeError, bug16603) { p(k:1, **42) }
end
end