changeset 23515:4d7928872999

Fix concatenation of a struct with an empty cell array (bug #39041) * pt-tm-const.cc (tm_row_const::tm_row_const_rep::do_init_element): Don't ignore empty cell array that occurs first in a row vector, allow structs to convert properly. * data.cc, pt-mat.cc: Add BIST tests for this fix. Add failing tests for a similar compatibility bug.
author Mike Miller <mtmiller@octave.org>
date Mon, 22 May 2017 12:12:45 -0700
parents fd7a16594614
children ed2239ed5fd3
files libinterp/corefcn/data.cc libinterp/parse-tree/pt-mat.cc libinterp/parse-tree/pt-tm-const.cc
diffstat 3 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Sun May 21 18:03:58 2017 -0700
+++ b/libinterp/corefcn/data.cc	Mon May 22 12:12:45 2017 -0700
@@ -2201,6 +2201,9 @@
 %!assert (class (horzcat (cell (1), struct ("foo", "bar"))), "cell")
 
 %!error horzcat (struct ("foo", "bar"), cell (1))
+
+%!test <39041> assert (class (horzcat (cell(0), struct())), "cell")
+%!test <51086> assert (class (horzcat (struct(), cell(0))), "struct")
 */
 
 DEFUN (vertcat, args, ,
--- a/libinterp/parse-tree/pt-mat.cc	Sun May 21 18:03:58 2017 -0700
+++ b/libinterp/parse-tree/pt-mat.cc	Mon May 22 12:12:45 2017 -0700
@@ -343,6 +343,9 @@
 %!assert (class ([cell(1), struct("foo", "bar")]), "cell")
 %!error [struct("foo", "bar"), cell(1)]
 
+%!test <39041> assert (class ([cell(0), struct()]), "cell")
+%!test <51086> assert (class ([struct(), cell(0)]), "struct")
+
 %!assert ([,1], 1)
 %!assert ([1,], 1)
 %!assert ([,1,], 1)
--- a/libinterp/parse-tree/pt-tm-const.cc	Sun May 21 18:03:58 2017 -0700
+++ b/libinterp/parse-tree/pt-tm-const.cc	Mon May 22 12:12:45 2017 -0700
@@ -82,6 +82,8 @@
             first_elem = false;
           }
       }
+    else if (val.is_cell ())
+      first_elem = false;
 
     append (val);