mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
FCALL shouldn't be forwarded from caller
When we forward an FCALL (a method call with an implicit self), we shouldn't forward the FCALL flag because it ignores method visibility checks. This patch removes the FCALL flag from callers. [Bug #21196]
This commit is contained in:
parent
aa7380f9d8
commit
00c6e537ce
2 changed files with 26 additions and 1 deletions
|
@ -1395,3 +1395,27 @@ assert_equal 'ok', %q{
|
|||
no_args
|
||||
splat_args
|
||||
}
|
||||
|
||||
assert_equal 'ok', %q{
|
||||
class A
|
||||
private
|
||||
def foo = "ng"
|
||||
end
|
||||
|
||||
class B
|
||||
def initialize(o)
|
||||
@o = o
|
||||
end
|
||||
|
||||
def foo(...) = @o.foo(...)
|
||||
def internal_foo = foo
|
||||
end
|
||||
|
||||
b = B.new(A.new)
|
||||
|
||||
begin
|
||||
b.internal_foo
|
||||
rescue NoMethodError
|
||||
"ok"
|
||||
end
|
||||
}
|
||||
|
|
|
@ -1177,7 +1177,8 @@ vm_caller_setup_fwd_args(const rb_execution_context_t *ec, rb_control_frame_t *r
|
|||
|
||||
*adjusted_ci = VM_CI_ON_STACK(
|
||||
site_mid,
|
||||
((caller_flag & ~VM_CALL_ARGS_SIMPLE) | (site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
|
||||
((caller_flag & ~(VM_CALL_ARGS_SIMPLE | VM_CALL_FCALL)) |
|
||||
(site_flag & (VM_CALL_FCALL | VM_CALL_FORWARDING))),
|
||||
site_argc + caller_argc,
|
||||
kw
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue