changeset 22253:dbf7fd79e391

More informative messages for errors in anonymous functions (bug #46136). * ov-usr-fcn.cc (octave_user_function::do_multi_index_op ()): If tree evaluator is bypassed for (is_special_expr ()), set location here. * call-stack.cc (octave_call_stack::stack_frame::fcn_name ()): Append octave_fcn_handle::anonymous to function name for anonymous functions.
author Olaf Till <olaf.till@uni-jena.de>
date Tue, 06 Oct 2015 12:12:56 +0200
parents 54dc5062879e
children daa81db564ac
files libinterp/corefcn/call-stack.cc libinterp/octave-value/ov-usr-fcn.cc
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/call-stack.cc	Wed Aug 10 10:28:00 2016 +0200
+++ b/libinterp/corefcn/call-stack.cc	Tue Oct 06 12:12:56 2015 +0200
@@ -30,6 +30,7 @@
 #include "oct-map.h"
 #include "ov.h"
 #include "ov-fcn.h"
+#include "ov-fcn-handle.h"
 #include "ov-usr-fcn.h"
 
 octave_call_stack *octave_call_stack::instance = 0;
@@ -52,7 +53,10 @@
       if (print_subfn && ! parent_fcn_name.empty ())
         retval = parent_fcn_name + Vfilemarker;
 
-      retval += m_fcn->name ();
+      if (m_fcn->is_anonymous_function ())
+        retval += octave_fcn_handle::anonymous;
+      else
+        retval += m_fcn->name ();
     }
   else
     retval = "<unknown>";
--- a/libinterp/octave-value/ov-usr-fcn.cc	Wed Aug 10 10:28:00 2016 +0200
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Tue Oct 06 12:12:56 2015 +0200
@@ -591,12 +591,20 @@
 
   if (is_special_expr ())
     {
-      tree_expression *expr = special_expr ();
+      assert (cmd_list->length () == 1);
+
+      tree_statement *stmt = cmd_list->front ();
+
+      tree_expression *expr = stmt->expression ();
 
       if (expr)
-        retval = (lvalue_list
-                  ? expr->rvalue (nargout, lvalue_list)
-                  : expr->rvalue (nargout));
+        {
+          octave_call_stack::set_location (stmt->line (), stmt->column ());
+
+          retval = (lvalue_list
+                    ? expr->rvalue (nargout, lvalue_list)
+                    : expr->rvalue (nargout));
+        }
     }
   else
     cmd_list->accept (*octave::current_evaluator);