Bug #16642 ยป ruby2_keywords-empty-kw-splat-16642.patch
test/ruby/test_keyword.rb | ||
---|---|---|
mock.new.foo
|
||
end
|
||
end
|
||
def test_ruby2_keywords_hash_empty_kw_splat
|
||
def self.foo(*a) a.last end
|
||
singleton_class.send(:ruby2_keywords, :foo)
|
||
bug16642 = '[ruby-core:97203] [Bug #16642]'
|
||
res = foo(**{})
|
||
assert_equal({}, res, bug16642)
|
||
assert_equal(false, res.frozen?, bug16642)
|
||
res = foo(*[], **{})
|
||
assert_equal({}, res, bug16642)
|
||
assert_equal(false, res.frozen?, bug16642)
|
||
end
|
||
end
|
vm_args.c | ||
---|---|---|
kw_flag &= ~VM_CALL_KW_SPLAT;
|
||
}
|
||
else {
|
||
if (RB_TYPE_P(rest_last, T_HASH) && rb_obj_frozen_p(rest_last)) {
|
||
rest_last = rb_hash_new();
|
||
RARRAY_ASET(args->rest, len - 1, rest_last);
|
||
}
|
||
flag_keyword_hash = rest_last;
|
||
}
|
||
}
|
||
... | ... | |
kw_flag &= ~VM_CALL_KW_SPLAT;
|
||
}
|
||
else {
|
||
if (RB_TYPE_P(last_arg, T_HASH) && rb_obj_frozen_p(last_arg)) {
|
||
last_arg = rb_hash_new();
|
||
args->argv[args->argc-1] = last_arg;
|
||
}
|
||
flag_keyword_hash = last_arg;
|
||
}
|
||
}
|