changeset 21180:a428c6ba6334

improve nargout error message (bug #47021) * ov-usr-fcn.cc (Fnargout): 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 23:51:45 -0500
parents 8bec8855e9ce
children a65b906e25bc
files libinterp/octave-value/ov-usr-fcn.cc
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc	Tue Feb 02 18:02:58 2016 -0500
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Tue Feb 02 23:51:45 2016 -0500
@@ -951,7 +951,7 @@
             return ovl (-1);
         }
 
-      octave_function *fcn_val = func.function_value ();
+      octave_function *fcn_val = func.function_value (true);
       if (! fcn_val)
         error ("nargout: FCN must be a string or function handle");
 
@@ -959,11 +959,12 @@
 
       if (! fcn)
         {
-          // JWE said this information is not available (2011-03-10)
-          // without making intrusive changes to Octave.
-          // Matlab gives up for histc,
-          // so maybe it's ok that we give up somtimes too?
-          error ("nargout: nargout 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 ("nargout: number of output arguments unavailable for %s objects",
+                 type.c_str ());
         }
 
       tree_parameter_list *ret_list = fcn->return_list ();