[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "pr
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error |
Date: |
Tue, 8 Feb 2022 08:43:08 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?62011>
Summary: addRequired of inputParser raising "protected
access" error
Project: GNU Octave
Submitted by: None
Submitted on: Tue 08 Feb 2022 01:43:06 PM UTC
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: None
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: 6.4.0
Discussion Lock: Any
Operating System: GNU/Linux
_______________________________________________________
Details:
The example for the usage of inputParser from the manual is not executable and
gives some strange error. The function code is copypasted (only renamed):
function parsertest (varargin)
p = inputParser (); # create object
p.FunctionName = "parsertest"; # set function name
p.addRequired ("pack", @ischar); # mandatory argument
p.addOptional ("path", pwd(), @ischar); # optional argument
## create a function handle to anonymous functions for validators
val_mat = @(x) isvector (x) && all (x <= 1) && all (x >= 0);
p.addOptional ("mat", [0 0], val_mat);
## create two arguments of type "Parameter"
val_type = @(x) any (strcmp (x, {"linear", "quadratic"}));
p.addParameter ("type", "linear", val_type);
val_verb = @(x) any (strcmp (x, {"low", "medium", "high"}));
p.addParameter ("tolerance", "low", val_verb);
## create a switch type of argument
p.addSwitch ("verbose");
p.parse (varargin{:}); # Run created parser on inputs
## the rest of the function can access inputs by using p.Results.
## for example, get the tolerance input with p.Results.tolerance
endfunction
Now calling the function as described in the manual gives an error:
parsertest("mech")
error: subsref: property 'Optional' has protected access and cannot be
obtained in this context
error: called from
addRequired at line 230 column 7
parsertest at line 4 column 3
I'm not sure whether this is a bug inside addRequired or a wrong description
in the manual…
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62011>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error,
anonymous <=
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Markus Mützel, 2022/02/08
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Rik, 2022/02/08
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Maxim Gawrilow, 2022/02/09
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Markus Mützel, 2022/02/09
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Eldrad Ulthran, 2022/02/09
- [Octave-bug-tracker] [bug #62011] addRequired of inputParser raising "protected access" error, Eldrad Ulthran, 2022/02/09
- [Octave-bug-tracker] [bug #62011] accessing protected property in classdef function raises access error after creating function handle, Markus Mützel, 2022/02/09