diff libinterp/octave-value/ov-usr-fcn.cc @ 16091:1785493171ac

pass lvalue_list to more subsref calls (bug #38374) * pt-id.h, pt-id.cc (tree_identifier::rvalue): Handle lvalue_list. * ov-cell.h, ov-cell.cc (octave_cell::subsref): Likewise. * ov.h, ov.cc (octave_value::next_subsref): Likewise. * ov-usr-fcn.cc (octave_usr_function::do_multi_index_op): Forward lvalue_list to rvalue call for special expression. (Fisargout): New tests.
author John W. Eaton <jwe@octave.org>
date Fri, 22 Feb 2013 19:01:10 -0500
parents 52df2e7baabe
children 0259254a3ccc 302157614308
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc	Fri Feb 22 11:22:21 2013 -0500
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Fri Feb 22 19:01:10 2013 -0500
@@ -481,7 +481,9 @@
       tree_expression *expr = special_expr ();
 
       if (expr)
-        retval = expr->rvalue (nargout);
+        retval = (lvalue_list
+                  ? expr->rvalue (nargout, lvalue_list)
+                  : expr->rvalue (nargout));
     }
   else
     cmd_list->accept (*current_evaluator);
@@ -1006,4 +1008,24 @@
 %!test
 %! [x, y] = try_isargout ();
 %! assert ([x, y], [1, 2]);
+%!
+%% It should work without ():
+%!test
+%! [~, y] = try_isargout;
+%! assert (y, -2);
+%!
+%% It should work in function handles, anonymous functions, and cell
+%% arrays of handles or anonymous functions.
+%!test
+%! fh = @try_isargout;
+%! af = @() try_isargout;
+%! c = {fh, af};
+%! [~, y] = fh ();
+%! assert (y, -2);
+%! [~, y] = af ();
+%! assert (y, -2);
+%! [~, y] = c{1}();
+%! assert (y, -2);
+%! [~, y] = c{2}();
+%! assert (y, -2);
 */