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

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

[Octave-bug-tracker] [bug #63841] nargout is always 0 or 1 for subsref()


From: Rik
Subject: [Octave-bug-tracker] [bug #63841] nargout is always 0 or 1 for subsref() in classdef methods
Date: Mon, 27 Feb 2023 11:58:00 -0500 (EST)

Follow-up Comment #10, bug #63841 (project octave):

I don't pretend this is brilliant, but this patch seems to fix the case for
the two reported bugs.


diff --git a/libinterp/octave-value/ov-classdef.cc
b/libinterp/octave-value/ov-classdef.cc
--- a/libinterp/octave-value/ov-classdef.cc
+++ b/libinterp/octave-value/ov-classdef.cc
@@ -102,8 +102,9 @@ octave_classdef::subsref (const std::str
             {
               // 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 (type[0] != '.')
+                tmp = idx.front ();
+              nargout = std::max (static_cast<int> (xnumel (tmp)), nargout);
             }
 
           retval = meth.execute (args, nargout, true, "subsref");


All it does is use the maximum value for nargout which is either the number of
output variables asked for by the interpeter (nargout input parameter to
function) or the maximum number of outputs for a varargout expression taken
from the index operation. 

(file #54400)

    _______________________________________________________

Additional Item Attachment:

File name: patch.63841                    Size:0 KB
    <https://file.savannah.gnu.org/file/patch.63841?file_id=54400>



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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