octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58686] Interpreter silently ignores inputs


From: Kai Torben Ohlhus
Subject: [Octave-bug-tracker] [bug #58686] Interpreter silently ignores inputs
Date: Wed, 1 Jul 2020 02:09:06 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?58686>

                 Summary: Interpreter silently ignores inputs
                 Project: GNU Octave
            Submitted by: siko1056
            Submitted on: Wed 01 Jul 2020 08:09:05 AM CEST
                Category: Interpreter
                Severity: 4 - Important
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: Need Info
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 6.0.90
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

Today I discovered Octave is ignoring an input and does not error or notify me
about it.  This applies for Octave 5.2.0, 6, and 7

I created a function and wrote an assert test for checking if it is working.

Unfortunately, I made a mistake and did not assign the result of my heavy
computation to "retval" properly.


function retval = do_nothing (n)
  
endfunction

%!assert (do_nothing (3), rand (3))


The worst is:  The test passed!?


>> test do_nothing
PASSES 1 out of 1 test


I analysed the problem and found, that the "octave_value_list" given to
"assert" has only one element.  This might be related when concatenating
"octave_values", and one is empty.

The following patch adds an ad-hoc detection:


diff -r 49f4d7814760 libinterp/parse-tree/pt-eval.cc
--- a/libinterp/parse-tree/pt-eval.cc   Mon Jun 29 15:01:27 2020 -0400
+++ b/libinterp/parse-tree/pt-eval.cc   Wed Jul 01 15:05:37 2020 +0900
@@ -2739,6 +2739,13 @@ namespace octave
     octave_value_list args (xargs);
     octave_value_list ret_args;
 
+    if (args.length () != xargs.name_tags ().numel ())
+      error ("DAMN!!!! Undefined elements!!"
+        "\n\targs.length () %d -  %d"
+        "\n\txargs.name_tags ().numel () %d -  %d",
+        args.length (), xargs.length (),
+        args.name_tags ().numel (), xargs.name_tags ().numel ());
+
     if (user_function.is_classdef_constructor ())
       {
         if (args.length () > 0)



Then


>> test do_nothing
***** assert (do_nothing (3), rand (3))
!!!!! test failed
DAMN!!!! Undefined elements!!
        args.length () 1 -  1
        xargs.name_tags ().numel () 2 -  2


Here it becomes obvious, that at the construction time of the argument
"octave_value_list" detected two "name_tags", but only the defined element is
passed ==> the "octave_value_list" is inconsistent.

I do not think, that my patch with detection is a good way to go.  Maybe
someone with more insight into the interpreter can make a check at the
construction time of the argument "octave_value_list" for non defined elements
and throw a proper error, like for example Matlab R2020b does.





    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58686>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]