mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_eval.c: fix hook call
* vm_eval.c (rb_check_funcall_with_hook): also should call the given hook before returning Qundef when overridden respond_to? method returned false. [ruby-core:73556] [Bug #12030] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
68241c2ea3
commit
6ee8ec7069
3 changed files with 18 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sat Jan 30 15:18:07 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_eval.c (rb_check_funcall_with_hook): also should call the
|
||||||
|
given hook before returning Qundef when overridden respond_to?
|
||||||
|
method returned false. [ruby-core:73556] [Bug #12030]
|
||||||
|
|
||||||
Fri Jan 29 17:40:07 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Jan 29 17:40:07 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* win32/file.c (rb_readlink): drop garbage after the substitute
|
* win32/file.c (rb_readlink): drop garbage after the substitute
|
||||||
|
|
|
@ -1324,6 +1324,15 @@ class TestHash < Test::Unit::TestCase
|
||||||
assert_equal({dug: [:foo, :bar]}, h.dig(:d, :foo, :bar))
|
assert_equal({dug: [:foo, :bar]}, h.dig(:d, :foo, :bar))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dig_with_respond_to
|
||||||
|
bug12030 = '[ruby-core:73556] [Bug #12030]'
|
||||||
|
o = Object.new
|
||||||
|
def o.respond_to?(*args)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
assert_raise(TypeError) {{foo: o}.dig(:foo, :foo)}
|
||||||
|
end
|
||||||
|
|
||||||
def test_cmp
|
def test_cmp
|
||||||
h1 = {a:1, b:2}
|
h1 = {a:1, b:2}
|
||||||
h2 = {a:1, b:2, c:3}
|
h2 = {a:1, b:2, c:3}
|
||||||
|
|
|
@ -478,8 +478,10 @@ rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
int respond = check_funcall_respond_to(th, klass, recv, mid);
|
int respond = check_funcall_respond_to(th, klass, recv, mid);
|
||||||
|
|
||||||
if (!respond)
|
if (!respond) {
|
||||||
|
(*hook)(FALSE, recv, mid, argc, argv, arg);
|
||||||
return Qundef;
|
return Qundef;
|
||||||
|
}
|
||||||
|
|
||||||
me = rb_search_method_entry(recv, mid);
|
me = rb_search_method_entry(recv, mid);
|
||||||
if (!check_funcall_callable(th, me)) {
|
if (!check_funcall_callable(th, me)) {
|
||||||
|
|
Loading…
Reference in a new issue