changeset 28548:605b9e811bf3

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Thu, 09 Jul 2020 13:04:54 -0400
parents 1c0a4e1b973e (current diff) 66397e171801 (diff)
children c89e1b6573e7
files libgui/src/m-editor/octave-qscintilla.cc libinterp/octave-value/ov-struct.cc libinterp/parse-tree/oct-parse.yy
diffstat 4 files changed, 27 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Wed Jul 08 08:15:27 2020 -0400
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Thu Jul 09 13:04:54 2020 -0400
@@ -810,7 +810,7 @@
     // Take selected code and extend it by commands for echoing each
     // evaluated line and for adding the line to the history (use script)
     QString code = QString ();
-    QString hist = QString ("### Begin selected code\n");
+    QString hist = QString ();
 
     // Split contents into single lines and complete commands
     QStringList lines = selectedText ().split (QRegExp ("[\r\n]"),
@@ -840,7 +840,6 @@
         hist += line_history + "\n";
       }
 
-    hist += "### End selected code\n";
     octave_stdout << hist.toStdString () << "\n";
 
     // Create tmp file with the code to be executed by the interpreter
--- a/libinterp/octave-value/ov-struct.cc	Wed Jul 08 08:15:27 2020 -0400
+++ b/libinterp/octave-value/ov-struct.cc	Thu Jul 09 13:04:54 2020 -0400
@@ -146,6 +146,9 @@
 
             const Cell t = tmp.index (idx.front ());
 
+            // Avoid creating a comma-separated list if the result is a
+            // single element.
+
             retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
 
             // We handled two index elements, so tell
@@ -162,8 +165,10 @@
       {
         const Cell t = dotref (idx.front ());
 
-        if (! map.isempty ())
-          retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
+        // Avoid creating a comma-separated list if the result is a
+        // single element.
+
+        retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
       }
       break;
 
@@ -207,6 +212,9 @@
 
             const Cell t = tmp.index (idx.front (), auto_add);
 
+            // Avoid creating a comma-separated list if the result is a
+            // single element.
+
             retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
 
             // We handled two index elements, so tell
@@ -225,6 +233,9 @@
           {
             const Cell t = dotref (idx.front (), auto_add);
 
+            // Avoid creating a comma-separated list if the result is a
+            // single element.
+
             retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
           }
       }
--- a/libinterp/parse-tree/oct-parse.yy	Wed Jul 08 08:15:27 2020 -0400
+++ b/libinterp/parse-tree/oct-parse.yy	Thu Jul 09 13:04:54 2020 -0400
@@ -3774,8 +3774,10 @@
   {
     tree_function_def *retval = nullptr;
 
-    if (ret_list)
-      ret_list->mark_as_formal_parameters ();
+    if (! ret_list)
+      ret_list = new tree_parameter_list (tree_parameter_list::out);
+
+    ret_list->mark_as_formal_parameters ();
 
     if (fcn)
       {
@@ -4200,8 +4202,10 @@
                                                 tree_parameter_list *ret_list,
                                                 comment_list *cl)
   {
-    if (ret_list)
-      fcn->define_ret_list (ret_list);
+    if (! ret_list)
+      ret_list = new tree_parameter_list (tree_parameter_list::out);
+
+    fcn->define_ret_list (ret_list);
 
     if (cl)
       fcn->stash_leading_comment (cl);
--- a/libinterp/parse-tree/pt-tm-const.cc	Wed Jul 08 08:15:27 2020 -0400
+++ b/libinterp/parse-tree/pt-tm-const.cc	Thu Jul 09 13:04:54 2020 -0400
@@ -171,7 +171,7 @@
         octave_value tmp = elt->evaluate (tw);
 
         if (tmp.is_undefined ())
-          continue;
+          error ("undefined element in matrix list");
 
         if (tmp.is_cs_list ())
           {
@@ -935,18 +935,11 @@
 %!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])
+%!test <58695>
+%! fail ("undefined element in matrix list", "[1; my_undef(), 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)
+%!test <58695>
+%! fail ("undefined element in matrix list", "[my_undef(); my_undef(); 3]")
 */