diff --git a/ChangeLog b/ChangeLog index 418dff755c..ca2154f59f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Mar 29 22:26:55 2016 Nobuyoshi Nakada + + * 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] + Tue Mar 29 22:08:36 2016 Kazuki Yamaguchi * compile.c (iseq_peephole_optimize): don't apply tailcall diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 6ee029722a..83c52a0c73 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1316,6 +1316,15 @@ class TestHash < Test::Unit::TestCase assert_equal({dug: [:foo, :bar]}, h.dig(:d, :foo, :bar)) 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 h1 = {a:1, b:2} h2 = {a:1, b:2, c:3} diff --git a/version.h b/version.h index 3127df53ea..c887f51e21 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-03-29" -#define RUBY_PATCHLEVEL 50 +#define RUBY_PATCHLEVEL 51 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 diff --git a/vm_eval.c b/vm_eval.c index 9c9f5fe705..ce95106fbb 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -478,8 +478,10 @@ rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv, rb_thread_t *th = GET_THREAD(); int respond = check_funcall_respond_to(th, klass, recv, mid); - if (!respond) + if (!respond) { + (*hook)(FALSE, recv, mid, argc, argv, arg); return Qundef; + } me = rb_search_method_entry(recv, mid); if (!check_funcall_callable(th, me)) {