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

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

[Octave-bug-tracker] [bug #36221] using ~ as optional output for unique


From: Ben Abbott
Subject: [Octave-bug-tracker] [bug #36221] using ~ as optional output for unique causes error in ismember
Date: Wed, 18 Apr 2012 16:23:57 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19

Update of bug #36221 (project octave):

                  Status:               Confirmed => In Progress            
             Assigned to:                    None => bpabbott               
        Operating System:       Microsoft Windows => Any                    

    _______________________________________________________

Follow-up Comment #3:

I wrote a simple function that isolates the problem.


function varargout = newdeal (varargin)
  for n = 1:nargin
    if (isargout (n))
      varargout(n) = varargin(n);
    endif
  endfor
  printf ("nargin = %d, nargout = %d, isargout(%d) = %d\n",
          nargin (), nargout (), nargout (), isargout (nargout ()))
endfunction

%!shared a1, a2, a3, b1, b2, b3, c1, c3
%! [a1, b1, c1] = newdeal (1, 2, 3);
%! [a2, b2,  ~] = newdeal (1, 2, 3);
%! [a3, b3, c3] = newdeal (1, 2, 3);
%!assert (a1, a2)
%!assert (a1, a3)
%!assert (b1, b2)
%!assert (b1, b3)
%!assert (c1, c3)


Running "test newdeal" ends with


test newdeal
nargin = 3, nargout = 3, isargout(3) = 1
nargin = 3, nargout = 3, isargout(3) = 0
  ***** shared a1, a2, a3, b1, b2, b3, c1, c3
 [a1, b1, c1] = newdeal (1, 2, 3);
 [a2, b2,  ~] = newdeal (1, 2, 3);
 [a3, b3, c3] = newdeal (1, 2, 3);
!!!!! test failed
element number 3 undefined in return list
shared variables 
  scalar structure containing the fields:

    a1 = [](0x0)
    a2 = [](0x0)
    a3 = [](0x0)
    b1 = [](0x0)
    b2 = [](0x0)
    b3 = [](0x0)
    c1 = [](0x0)
    c3 = [](0x0)


The parser expects the third argument to be set when the "~" is present. I
think this is intended. Thus, unique.m should be rewritten to use "(nargout ()
<= n)" in place of "isargout (n)". For example, modifying the simple example,
the version below passes all tests.


function varargout = newdeal (varargin)
  nout = nargout ();
  isargout = @(n) nout >= n;
  for n = 1:nargin
    if (isargout (n))
      varargout(n) = varargin(n);
    endif
  endfor
  printf ("nargin = %d, nargout = %d, isargout(%d) = %d\n",
          nargin (), nargout (), nargout (), isargout (nargout ()))
endfunction

%!shared a1, a2, a3, b1, b2, b3, c1, c3
%! [a1, b1, c1] = newdeal (1, 2, 3);
%! [a2, b2,  ~] = newdeal (1, 2, 3);
%! [a3, b3, c3] = newdeal (1, 2, 3);
%!assert (a1, a2)
%!assert (a1, a3)
%!assert (b1, b2)
%!assert (b1, b3)
%!assert (c1, c3)



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?36221>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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