changeset 32158:583c0ed2bc8f

inputParser.m: Fix regression with UsingDefaults (bug #64318) * inputParser.m (add_missing): Transpose variable 'unmatched_names' before concatenation with 'UsingDefaults'. * inputParser.m: Add BIST test for bug #64318.
author Rik <rik@octave.org>
date Wed, 21 Jun 2023 11:49:39 -0700
parents abce709e0b60
children 93d3bcced10e
files scripts/miscellaneous/inputParser.m
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/inputParser.m	Wed Jun 21 10:47:50 2023 -0700
+++ b/scripts/miscellaneous/inputParser.m	Wed Jun 21 11:49:39 2023 -0700
@@ -674,7 +674,7 @@
         this.Results = ...
           cell2struct (vertcat (struct2cell (this.Results), unmatched_def),
                        [Resultnames; unmatched_names]);
-        this.UsingDefaults = [this.UsingDefaults, unmatched_names];
+        this.UsingDefaults = [this.UsingDefaults, unmatched_names.'];
       endif
 
     endfunction
@@ -1052,4 +1052,10 @@
 %! assert (p.Results.year, 1980);
 %! assert (p.Results.color, 'black');
 
-
+%!test <*64318>
+%! p = inputParser;
+%! p.addOptional ('p_opt', []);
+%! p.addParameter ('p1', 'p1_default');
+%! p.addParameter ('p2', 'p2_default');
+%! p.parse ();
+%! assert (size (p.UsingDefaults), [1, 3]);