diff -r 5ed7e78d09ae libinterp/octave-value/ov-classdef.cc
--- a/libinterp/octave-value/ov-classdef.cc	Fri Mar 24 14:07:43 2023 +0100
+++ b/libinterp/octave-value/ov-classdef.cc	Thu Apr 06 11:19:36 2023 +0200
@@ -91,28 +91,41 @@
           m_count++;
           args(0) = octave_value (this);
 
-          // Attempt to set up a proper value for nargout at least in the
-          // simple case where the cs-list-type expression - i.e., {} or
-          // ().x, is the leading one.
-          bool maybe_cs_list_query = (type[0] == '.' || type[0] == '{'
-                                      || (type.length () > 1 && type[0] == '('
-                                          && type[1] == '.'));
+          // If the number of output arguments is unknown, attempt to set up
+          // a proper value for nargout at least in the simple case where the
+          // cs-list-type expression - i.e., {} or ().x, is the leading one.
+          if (nargout <= 0)
+            {
+              bool maybe_cs_list_query = (type[0] == '.' || type[0] == '{'
+                                          || (type.length () > 1 && type[0] == '('
+                                              && type[1] == '.'));
 
-          if (maybe_cs_list_query)
-            {
-              // Set up a proper nargout for the subsref call by calling numel.
-              octave_value_list tmp;
-              if (type[0] != '.') tmp = idx.front ();
-              nargout = xnumel (tmp);
+              if (maybe_cs_list_query)
+                {
+                  // Set up a proper nargout for the subsref call by calling numel.
+                  octave_value_list tmp;
+                  if (type[0] != '.') tmp = idx.front ();
+                  nargout = xnumel (tmp);
+                }
+              else
+                nargout = 1;
             }
 
           retval = meth.execute (args, nargout, true, "subsref");
 
-          // Since we're handling subsref, if the list has more than one
-          // element, return it as a comma-separated list so that we can
-          // pass it to the evaluator
-          if (retval.length () > 1)
-            retval = octave_value (retval);
+          // Since we're handling subsref, if the list has more than one element
+          // and the caller to subsref accepts more that one output, return
+          // the elements as a comma-separated list so that we can pass it to the
+          // evaluator
+          if (nargout != 1 && retval.length () > 1)
+            {
+              if (nargout <= 0 || nargout>retval.length())
+                  // Take the whole list
+                  retval = octave_value (retval);
+              else
+                  // Take nargout elements of the list
+                  retval = octave_value(retval.slice(0,nargout));
+            }
 
           return retval;
         }
diff -r 5ed7e78d09ae libinterp/parse-tree/pt-eval.cc
--- a/libinterp/parse-tree/pt-eval.cc	Fri Mar 24 14:07:43 2023 +0100
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Apr 06 11:19:36 2023 +0200
@@ -2283,7 +2283,8 @@
       if (! elt)
         break;
 
-      octave_value tmp = elt->evaluate (*this);
+      // Evaluate with unkown number of output arguments
+      octave_value tmp = elt->evaluate (*this, -1);
 
       if (tmp.is_cs_list ())
         {
@@ -3358,6 +3359,11 @@
 
   octave_builtin::fcn fcn = builtin_function.function ();
 
+  // If number of outputs unknown (and this is not a complete statement),
+  // pass nargout=1 to the function being called
+  if (nargout < 0)
+    nargout = 1;
+
   if (fcn)
     retval = (*fcn) (args, nargout);
   else
@@ -3401,6 +3407,11 @@
 
   profiler::enter<octave_mex_function> block (m_profiler, mex_function);
 
+  // If number of outputs unknown (and this is not a complete statement),
+  // pass nargout=1 to the function being called
+  if (nargout < 0)
+    nargout = 1;
+
   retval = call_mex (mex_function, args, nargout);
 
   return retval;
@@ -3471,6 +3482,11 @@
 
   int nargin = args.length ();
 
+  // If number of outputs unknown (and this is not a complete statement),
+  // pass nargout=1 to the function being called
+  if (nargout < 0)
+    nargout = 1;
+  
   if (user_function.is_classdef_constructor ())
     {
       if (nargin > 0)
diff -r 5ed7e78d09ae libinterp/parse-tree/pt-tm-const.cc
--- a/libinterp/parse-tree/pt-tm-const.cc	Fri Mar 24 14:07:43 2023 +0100
+++ b/libinterp/parse-tree/pt-tm-const.cc	Thu Apr 06 11:19:36 2023 +0200
@@ -168,7 +168,8 @@
     {
       octave_quit ();
 
-      octave_value tmp = elt->evaluate (tw);
+      // Evaluate with unkown number of output arguments
+      octave_value tmp = elt->evaluate (tw,-1);
 
       if (tmp.is_undefined ())
         error ("undefined element in matrix list");
