octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #64783] Default number of output arguments not


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #64783] Default number of output arguments not 1 for anonymous functions
Date: Tue, 30 Jan 2024 14:03:55 -0500 (EST)

Follow-up Comment #3, bug#64783 (group octave):

Here is a possible fix.


diff --git a/libinterp/octave-value/ov-fcn-handle.cc
b/libinterp/octave-value/ov-fcn-handle.cc
--- a/libinterp/octave-value/ov-fcn-handle.cc
+++ b/libinterp/octave-value/ov-fcn-handle.cc
@@ -2785,7 +2785,17 @@ anonymous_fcn_handle::call (int nargout,
 
   unwind_action act ([&tw] () { tw.pop_stack_frame (); });
 
-  return oct_usr_fcn->execute (tw, nargout, args);
+  octave_value_list retval = oct_usr_fcn->execute (tw, nargout, args);
+
+  // FIXME: Is this the correct (or best) place for the following check
+  // and transformation?
+
+  // 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 ();
+
+  return retval;
 }
 
 octave_value




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64783>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]