bugGNU Octave - Bugs: bug #45496, "error: no default value for...

 
 

bug #45496: "error: no default value for argument" fails to give function/line number/etc

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Wed 08 Jul 2015 03:03:49 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  None
Originator Name:  Nick Jankowski Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 04 Aug 2015 10:09:51 PM UTC, comment #3: 

I'm not exactly sure why Octave even had the newline on this error message which was suppressing the backtrace.  If you look at other calls to error() within the file pt-misc.cc they do not use a newline.  Similarly, using grep 'error (' in the parse-tree directory this was the only example which ended in a newline.  So, I'm guessing this was just an oversight.  I removed the newline and now Octave prints a backtrace for this error.  The line number and column number are wrong because Octave has not actually started to parse the function so it returns -1 for these values.  But I found it enough for debugging to see


error: no default value for argument 1
error: called from
    myf at line -1 column -1


where the function was in the file myf.m

The change was made on the default branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/58b02a8d0fe9) and will be part of the 4.2 release of Octave.  If you need it immediately you can compile from source code.

Rik <rik5>
Group administrator
Thu 09 Jul 2015 01:13:22 AM UTC, comment #2: 


> what is that supposed to do?


I didn't realize Octave supported this, but apparently a : as a function input is a placeholder for whatever default value is specified in the function definition.

For me, it was a typo. Since the error wasn't reporting tho stack trace, it took me a bit to find the source of the error.
 It was buried in a function I wrote to do a fast matrix multiply between arrays of 2x2 matrices. (attached)

I had misordered by inputs to the calling function, so instead of getting two arrays to multiply, it was passed an array and a function handle instead.

You can see in the attached file, it rolls out the matrix multiply, calling each element by A(1,1,:), etc.  So, since it saw A as a function handle, it got rightly confused.

legitimate error. no stack trace. :)

(file #34399)

Nicholas Jankowski <nrjank>
Group Member
Thu 09 Jul 2015 12:14:01 AM UTC, comment #1: 

The error comes from this line:

http://hg.savannah.gnu.org/hgweb/octave/file/release-4-0-0/libinterp/parse-tree/pt-misc.cc#l203

The error function prints a stack trace by default, but when the error string ends in a newline it suppresses the stack trace, which is what you're seeing here.

So it looks like this specific error happens when you call a function with a colon as the argument value and the function hasn't been declared when a default argument value. I'm not even sure I've seen that syntax, what is that supposed to do?

Mike Miller <mtmiller>
Group Member
Wed 08 Jul 2015 03:03:49 PM UTC, original submission:  

working on a model with a rather involved script where a I was getting

error: no default value for argument 3

The problem is I had no idea were the error was being generated. Turns out, it was about 3 levels down. I had to manually step through the scripts/functions until arriving at the source of the error.  Just to make sure normal errors report correctly, I deliberately created a multiplication mismatch on the line before the one causing the default argument error, and sure enough it reported:


debug> dbstep
error: binary operator '*' not implemented for 'matrix' by 'function handl
e' operations
error: called from
    etafn at line 34 column 9
    Yangmodel_transientprofiles> at line -1 column -1
    Yangmodel_output at line 24 column 32


removing that error, and rerunning the same script, and the only output it provided was:


debug> dbstep
error: no default value for argument 3


Not sure if there's a reason why the error would be unable to display the full error trace. if it matters, etafn is a subfunction defined within the script Yangmodel_transientprofiles, later called from Yangmodel_output.  I'm in the process of moving the functions out to separate files for ML compatibility, but hadn't gotten there yet. don't know if that affects anything about the trace.

I'd rather not post my full messy model. I hadn't messed with default values before, but I can try to create a simplified case if it seems necessary.


Nicholas Jankowski <nrjank>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #34399:  twobytwoarraymult.m added by nrjank (1004B - text/x-objcsrc - function to matrix multipy arrays of 2x2 matrices)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by nrjank (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-08-04 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-07-09 nrjank Attached File- Added twobytwoarraymult.m, #34399
    2015-07-09 mtmiller StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code