changeset 32891:ff1d5873f805 stable

don't allow anon fcn eval to return comma-separated list (bug #64783) * pt-eval.cc (tree_evaluator::execute_user_function): If evaluation of an anonymous function (special_expr) results in a comma-separated list, return the first element of the list, not the comma-separated list itself.
author John W. Eaton <jwe@octave.org>
date Wed, 31 Jan 2024 17:28:04 -0500
parents 258444f64447
children 80d3a6abfc4d
files libinterp/parse-tree/pt-eval.cc
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-eval.cc	Wed Jan 31 17:25:41 2024 -0500
+++ b/libinterp/parse-tree/pt-eval.cc	Wed Jan 31 17:28:04 2024 -0500
@@ -3678,6 +3678,11 @@
               m_call_stack.set_location (stmt->line (), stmt->column ());
 
               retval = expr->evaluate_n (*this, nargout);
+
+              // Don't allow a comma-separated list to escape (see bug #64783).
+
+              if (nargout <= 1 && retval.length () == 1 && retval(0).is_cs_list ())
+                retval = retval(0).list_value ();
             }
         }
       else