bugGNU Octave - Bugs: bug #62418, inputParser fails because of...

 
 

bug #62418: inputParser fails because of function not returning argument

Submitter:  Georg Wiora <gwiora>
Submitted:  Thu 05 May 2022 02:23:05 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Wont Fix Assigned to:  None
Originator Name:  gwiora Open/Closed:  * Closed
Release:  * 7.1.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 06 May 2022 06:37:00 AM UTC, comment #2: 

Thank you for the hint to news file. This means that the interpreter is OK, but inputParser class needs to be fixed. I will file a new bug report for this.

Georg Wiora <gwiora>
Thu 05 May 2022 05:49:49 PM UTC, comment #1: 

This was changed for compatibility with Matlab. It also fails there:

>> {pack()}
Error using pack
Too many output arguments.


The equivalent in Octave 7.1.0:

>> {pack()}
error: pack: function called with too many outputs
error: called from
    pack


See also this note in the NEWS file for Octave 7:
https://hg.savannah.gnu.org/hgweb/octave/file/302faf5bc425/etc/NEWS.7.md#l38

> - Calling a user-defined function with too many inputs or outputs is now
> an error.  The interpreter makes this check automatically.  If a
> function uses varargin then the check is skipped for function inputs,
> and if a function uses varargout then the check is skipped for function
> outputs.  Input validation for functions typically begins with checking
> that the number of inputs and outputs match expectations.  Existing code
> can be simplified by removing these checks which are now done by the
> interpreter.  Typically, code blocks like the following can simply be
> deleted.
>
>         ## Checking number of inputs
>         if (nargin > 2)
>           print_usage ();
>         endif
>
>         ## Checking number of outputs
>         if (nargout > 1)
>           print_usage ();
>         endif


Like described in the NEWS file, one way to adapt your code would be to define the function in the function handle `v` with `varargout`.

Overall, this is an expected change in behavior between Octave 6 (and earlier) and 7 (and later).

Closing as won't fix.

Markus Mützel <mmuetzel>
Group administrator
Thu 05 May 2022 02:23:05 PM UTC, original submission:  

The validate_arg function fails in octave 7.1.0 at the marked position while it worked up to 6.4

function validate_arg (this, name, val, in)
        % Check validation result to be empty in case of the use of validateattributes function
        % An empty result will be interpreted as valid arguments
-->        check = {val(in)};
        if (~isempty(check) && ~val(in))
          this.error (sprintf ("failed validation of %s with %s", toupper (name),func2str(val)));
        endif
        this.Results.(name) = in;
    endfunction


The reason is that val() is a function handle for validateattributes() that checks the validity of the in parameter and does only return a result if the test fails. If everything is ok it does not return a result.
This seems to be checked by the interpreter in the cell array operator: {val(in)} and the interpreter produces the follwoing error message:

error: validateattributes: function called with too many outputs
error: called from
    validateattributes
    dirPlus>@<anonymous> at line 142 column 22
    validate_arg at line 507 column 15
    parse at line 394 column 9
    dirPlus at line 177 column 3
    SPF_OctaveJobEval at line 62 column 11
stopped in validate_arg at line 507 [C:\Software\SPF_Backend_as\deployment\octave_service_image\workspace\inputParser.m]


It seems that the interpreter insists on having an output when called inside the cell array operator. This is different from the previous behaviour.

Georg Wiora <gwiora>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by gwiora (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-05 mmuetzel StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code