Mercurial > octave
changeset 28542:c318254c9f01 stable
accept and ignore undefined elements in matrix concatentation (bug #58695)
* pt-tm-const.cc (tm_row_const::init, tm_const::init): Continue if an
undefined element (or empty row) is found instead of returning early
and producing an undefined row (or empty array).
New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jul 2020 07:56:36 -0400 |
parents | ea5a632b2553 |
children | 1c0a4e1b973e dc53b7b7af8b |
files | libinterp/parse-tree/pt-tm-const.cc |
diffstat | 1 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-tm-const.cc Tue Jul 07 18:34:23 2020 -0400 +++ b/libinterp/parse-tree/pt-tm-const.cc Wed Jul 08 07:56:36 2020 -0400 @@ -171,7 +171,7 @@ octave_value tmp = elt->evaluate (tw); if (tmp.is_undefined ()) - return; + continue; if (tmp.is_cs_list ()) { @@ -318,7 +318,7 @@ } if (row.empty ()) - break; + continue; if (m_all_strings && ! row.all_strings_p ()) m_all_strings = false; @@ -927,4 +927,26 @@ %!assert (isnull ([;;])) %!assert (isnull ([;,;])) %!assert (isnull ([,;,;,])) + +## Undefined elements. +%!function my_undef () +%!endfunction +%! +%!shared es +%! es = struct ("a", {}); +%! +%!assert <58695> ([1, es.a, 3], [1, 3]) +%!assert <58695> ([1, my_undef(), 3], [1, 3]) +%! +%!assert <58695> ([es.a, es.a, 3], 3) +%!assert <58695> ([my_undef(), my_undef(), 3], 3) +%! +%!assert <58695> ([1; es.a; 3], [1; 3]) +%!assert <58695> ([1; my_undef(), 3], [1; 3]) +%! +%!assert <58695> ([es.a; es.a; 3], 3) +%!assert <58695> ([my_undef(); my_undef(); 3], 3) +%! +%!assert <58695> ([es.a; es.a; 3], 3) +%!assert <58695> ([my_undef(); my_undef(); 3], 3) */