[Top][All Lists]

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

[Octave-bug-tracker] [bug #62639] imputParser fails to add Optional argu

From: anonymous
Subject: [Octave-bug-tracker] [bug #62639] imputParser fails to add Optional argument with empty cell default value
Date: Thu, 16 Jun 2022 07:45:19 -0400 (EDT)


                 Summary: imputParser fails to add Optional argument with
empty cell default value
                 Project: GNU Octave
               Submitter: None
               Submitted: Thu 16 Jun 2022 11:45:16 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nikita Beliy
        Originator Email: nikita.beliy@uliege.be
             Open/Closed: Open
                 Release: 5.2.0
         Discussion Lock: Any
        Operating System: GNU/Linux


Follow-up Comments:

Date: Thu 16 Jun 2022 11:45:16 AM UTC By: Anonymous
When creating argument parser with an empty optional argument:


> p = inputParser;
> p.addOptional('opt',{});
> p.parse('opt', 'xxx')

fails with error:

 error: value on right hand side of assignment is undefined
 error: called from
   parse at line 441 column 35

In Matlab (R2017b) works as expected:


>> p = inputParser;
>> p.addOptional('opt',{});
>> p.parse('opt', 'xxx');
>> p.Results
ans = 

  struct with fields:

    opt: 'xxx'

The problem comes from inputParser.m:324:

this.Optional{end+1} = struct ("name", name, "def", def, "val", val);

The creation of structure with an empty cell as value creates an empty
structure (both in matlab and octave):


> sp = struc(p);
> sp.Optional
ans =
  [1,1] =

    0x0 struct array containing the fields:




>> sp = struct(p);
>> sp.Optional   

ans = 

  struct with fields:

         name: 'opt'
      default: {}
    validator: []

P.S. Can't test later versions of octave, the 5.2.0-1 is the latest one for
Ubuntu 20.04


Reply to this item at:


Message sent via Savannah

reply via email to

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