Mercurial > octave
diff libinterp/parse-tree/pt-assign.cc @ 28193:56c209ff0a08 stable
improve handling of ans assignment with wrapper functions
* oct-lvalue.h, oct-lvalue.cc (octave_lvalue::index_is_colon):
New function.
* pt-assign.cc (tree_multi_assignment::evaluate_n): Also handle result
value when LHS is [varargout{:}] and varargout is defined but empty.
* args.tst: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Apr 2020 14:56:27 -0400 |
parents | bd51beb6205e |
children | ea5a632b2553 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-assign.cc Tue Apr 07 08:42:31 2020 +0200 +++ b/libinterp/parse-tree/pt-assign.cc Wed Apr 08 14:56:27 2020 -0400 @@ -226,14 +226,24 @@ // // [varargout{1:nargout}] = fcn (args); // + // or + // + // varargout = cell (1, nargout); + // [varargout{1:nargout}] = fcn (args); + // + // or + // + // varargout = cell (1, nargout); + // [varargout{:}] = fcn (args); + // // Will work the same as calling fcn directly when nargout // is 0 and fcn produces more than one output even when - // nargout is 0. This only works if varargout has not yet - // been defined. See also bug #43813. + // nargout is 0. See also bug #43813. if (lvalue_list.size () == 1 && nel == 0 && n > 0 - && ! ult.is_black_hole () && ult.is_undefined () - && ult.index_type () == "{" && ult.index_is_empty ()) + && ! ult.is_black_hole () && ult.index_type () == "{" + && (ult.index_is_empty () + || (ult.is_defined () && ult.index_is_colon ()))) { // Convert undefined lvalue with empty index to a cell // array with a single value and indexed by 1 to