comparison libinterp/octave-value/ov-classdef.cc @ 31652:a18897e4c7b5

classdef: call subsref method with correct nargout value (bug #48693) * /libinterp/octave-value/ov-classdef.cc (octave_classdef::subsref): Correct the nargout value for classdef subsref calls by checking the number of values the indexing argument addresses, using the same code used by the non-classdef subsref method. * /test/bug-48693/bug-48693.tst, bug48693.m, module.mk: Add simple test function files to verify subsref behavior.
author Fernando Alvarruiz <feralber@upvnet.upv.es>
date Wed, 07 Dec 2022 22:37:28 -0500
parents aac27ad79be6
children 5f11de0e7440
comparison
equal deleted inserted replaced
31651:beb7f91a0a97 31652:a18897e4c7b5
89 args(1) = make_idx_args (type, idx, "subsref"); 89 args(1) = make_idx_args (type, idx, "subsref");
90 90
91 count++; 91 count++;
92 args(0) = octave_value (this); 92 args(0) = octave_value (this);
93 93
94 // Attempt to set up a proper value for nargout at least in the
95 // simple case where the cs-list-type expression - i.e., {} or
96 // ().x, is the leading one.
97 bool maybe_cs_list_query = (type[0] == '.' || type[0] == '{'
98 || (type.length () > 1 && type[0] == '('
99 && type[1] == '.'));
100
101 if (maybe_cs_list_query)
102 {
103 // Set up a proper nargout for the subsref call by calling numel.
104 octave_value_list tmp;
105 if (type[0] != '.') tmp = idx.front ();
106 nargout = xnumel (tmp);
107 }
108
94 retval = meth.execute (args, nargout, true, "subsref"); 109 retval = meth.execute (args, nargout, true, "subsref");
110
111 // Since we're handling subsref, if the list has more than one
112 // element, return it as a comma-separated list so that we can
113 // pass it to the evaluator
114 if (retval.length () > 1)
115 retval = octave_value (retval);
95 116
96 return retval; 117 return retval;
97 } 118 }
98 } 119 }
99 120