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

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

[Octave-bug-tracker] [bug #59265] Partial assignment of outputs for some


From: Rik
Subject: [Octave-bug-tracker] [bug #59265] Partial assignment of outputs for some error conditions
Date: Tue, 13 Oct 2020 21:14:34 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?59265>

                 Summary: Partial assignment of outputs for some error
conditions
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Tue 13 Oct 2020 06:14:33 PM PDT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: Confirmed
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

Sample code:


[a,b] = newline ()
error: element number 2 undefined in return list
a = 

double (a)
ans = 10


The newline() function only produces one output so I would expect that since
this is an incorrect way to call the function I would get an error.  This is
what Matlab does.  It throws an error about calling newline() with too many
output arguments.

Note that the correct error is thrown if the function is defined in an m-file.
 Consider the following newline2.m function


function retval = newline2 ()
  retval = "\n";
endfunction


When called from the command line


[a,b] = newline2 ()
error: newline2: function called with too many outputs
error: called from
    newline2


So the problem is only exhibited for built-in C++ functions.  For reference,
the code for newline in strfns.cc is


  if (args.length () != 0)
    print_usage ();

  static octave_value_list retval = ovl ("\n");

  return retval;


It would seem that either C++ code needs to explicitly check nargout (which
means modifying lots and lots of functions), or we need to communicate to the
interpreter via the DEFUN macro how many output arguments are expected and
have the interpreter check that.  The second approach also requires lots and
lots of changes.
 




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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