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

[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)

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

                 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:

*octave:*

> 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:

*matlab:*

>> 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):

*octave:*

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

    0x0 struct array containing the fields:

      name
      def
      val

}


*matlab:*

>> 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:

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

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




reply via email to

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