changeset 21179:8bec8855e9ce

improve nargin error message (bug #47021) * ov-usr-fcn.cc (Fnargin): Pass true to octave_value::function_value. Display type name in error if object is not a user-defined function.
author John W. Eaton <jwe@octave.org>
date Tue, 02 Feb 2016 18:02:58 -0500
parents 3be6a07e8bad
children a428c6ba6334
files libinterp/octave-value/ov-usr-fcn.cc
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc	Tue Feb 02 17:06:11 2016 -0500
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Tue Feb 02 18:02:58 2016 -0500
@@ -832,7 +832,7 @@
             error ("nargin: invalid function name: %s", name.c_str ());
         }
 
-      octave_function *fcn_val = func.function_value ();
+      octave_function *fcn_val = func.function_value (true);
       if (! fcn_val)
         error ("nargin: FCN must be a string or function handle");
 
@@ -840,9 +840,12 @@
 
       if (! fcn)
         {
-          // Matlab gives up for histc,
-          // so maybe it's ok that that we give up somtimes too?
-          error ("nargin: nargin information not available for built-in functions");
+          // Matlab gives up for histc, so maybe it's ok that that we
+          // give up sometimes too?
+
+          std::string type = fcn_val->type_name ();
+          error ("nargin: number of input arguments unavailable for %s objects",
+                 type.c_str ());
         }
 
       tree_parameter_list *param_list = fcn->parameter_list ();