From 4d9f5482aea747e614a8d78b5e8ec114b023a768 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 28 Feb 2016 04:41:38 +0000 Subject: NoMethodError#private_call? * error.c (nometh_err_initialize): add private_call? parameter. * error.c (nometh_err_private_call_p): add private_call? method, to tell if the exception raised in private form FCALL or VCALL. [Feature #12043] * vm_eval.c (make_no_method_exception): append private_call? argument. * vm_insnhelper.c (ci_missing_reason): copy FCALL flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_eval.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'vm_eval.c') diff --git a/vm_eval.c b/vm_eval.c index 5bdc948c75..7eda5c24d8 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -682,13 +682,15 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj) } static VALUE -make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv) +make_no_method_exception(VALUE exc, VALUE format, VALUE obj, + int argc, const VALUE *argv, int priv) { int n = 0; enum { arg_mesg, arg_name, arg_args, + arg_priv, args_size }; VALUE args[args_size]; @@ -700,6 +702,7 @@ make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VAL args[n++] = argv[0]; if (exc == rb_eNoMethodError) { args[n++] = rb_ary_new4(argc - 1, argv + 1); + args[n++] = priv ? Qtrue : Qfalse; } return rb_class_new_instance(n, args, exc); } @@ -737,7 +740,8 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj, } { - exc = make_no_method_exception(exc, format, obj, argc, argv); + exc = make_no_method_exception(exc, format, obj, argc, argv, + last_call_status & (MISSING_FCALL|MISSING_VCALL)); if (!(last_call_status & MISSING_MISSING)) { rb_vm_pop_cfunc_frame(); } @@ -929,7 +933,8 @@ send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope) if (!id) { if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) { VALUE exc = make_no_method_exception(rb_eNoMethodError, 0, - recv, argc, argv); + recv, argc, argv, + scope != CALL_PUBLIC); rb_exc_raise(exc); } if (!SYMBOL_P(*argv)) { -- cgit v1.2.3