# HG changeset patch # User Markus Mützel # Date 1654518486 -7200 # Node ID bcadacfac44f5a584accae2518268699030b1331 # Parent 396f60e0b984cc90a1766cd99a1573e0f9265e23# Parent 2c8ab613e805ba13f183ce0a1503c76957e641ab maint: Merge stable to default. diff -r 396f60e0b984 -r bcadacfac44f scripts/miscellaneous/inputParser.m --- a/scripts/miscellaneous/inputParser.m Sun Jun 05 18:11:28 2022 -0400 +++ b/scripts/miscellaneous/inputParser.m Mon Jun 06 14:28:06 2022 +0200 @@ -543,9 +543,29 @@ function validate_arg (this, name, val, in) - if (! val (in)) - this.error (sprintf ("failed validation of %s with %s", - toupper (name), func2str (val))); + ## Checking "nargout (val)" doesn't work for builtin functions. + ## So, we need to use this nested try-catch construct. + err = sprintf ('Checked with "%s"', func2str (val)); + try + ok = val (in); + catch exception + if (strcmp (exception.identifier, "Octave:invalid-fun-call")) + ## check if function also fails when called without output argument + try + val (in); + ok = true; + catch exception + ok = false; + err = exception.message; + end_try_catch + else + ok = false; + err = exception.message; + endif + end_try_catch + if (! ok) + this.error (sprintf ("failed validation of %s. %s", + toupper (name), err)); endif this.Results.(name) = in; @@ -859,7 +879,7 @@ %! assert (p.Unmatched, struct ()); ## Test for patch #9241 -%!error +%!error %! p = inputParser (); %! p.addParameter ("a", [], @ischar); %! p.parse ("a", 1);