mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
fix bug in keyword + protected combination
Test included for the situation formerly was not working.
This commit is contained in:
parent
a72cb6b11d
commit
cc5580f175
2 changed files with 25 additions and 2 deletions
|
@ -4859,4 +4859,20 @@ class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase
|
||||||
assert_equal([1, h3], c.call(**h3, &:m2))
|
assert_equal([1, h3], c.call(**h3, &:m2))
|
||||||
assert_equal([1, h3], c.call(a: 1, **h2, &:m2))
|
assert_equal([1, h3], c.call(a: 1, **h2, &:m2))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_protected_kwarg
|
||||||
|
mock = Class.new do
|
||||||
|
def foo
|
||||||
|
bar('x', y: 'z')
|
||||||
|
end
|
||||||
|
protected
|
||||||
|
def bar(x, y)
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_nothing_raised do
|
||||||
|
mock.new.foo
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2879,10 +2879,17 @@ vm_call_method(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_ca
|
||||||
else {
|
else {
|
||||||
/* caching method info to dummy cc */
|
/* caching method info to dummy cc */
|
||||||
VM_ASSERT(cc->me != NULL);
|
VM_ASSERT(cc->me != NULL);
|
||||||
|
if (ci->flag & VM_CALL_KWARG) {
|
||||||
|
struct rb_kwarg_call_data *kcd = (void *)cd;
|
||||||
|
struct rb_kwarg_call_data cd_entry = *kcd;
|
||||||
|
return vm_call_method_each_type(ec, cfp, calling, (void *)&cd_entry);
|
||||||
|
}
|
||||||
|
else {
|
||||||
struct rb_call_data cd_entry = *cd;
|
struct rb_call_data cd_entry = *cd;
|
||||||
return vm_call_method_each_type(ec, cfp, calling, &cd_entry);
|
return vm_call_method_each_type(ec, cfp, calling, &cd_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return vm_call_method_each_type(ec, cfp, calling, cd);
|
return vm_call_method_each_type(ec, cfp, calling, cd);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Reference in a new issue