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

Submitted by:  Nicholas Jankowski <nrjank>
Submitted on:  Wed 08 Jul 2015 03:03:49 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Other
Status: FixedAssigned to: None
Originator Name: Nick JankowskiOpen/Closed: Closed
Release: 4.0.0Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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

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>
Project 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>
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>
Project Administrator
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:

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

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>

 

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

Attach File(s):
   
   
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
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by nrjank (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 04 Aug 2015 10:09:51 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Thu 09 Jul 2015 01:13:22 AM UTCnrjankAttached File-=>Added twobytwoarraymult.m, #34399
    Thu 09 Jul 2015 12:14:01 AM UTCmtmillerStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1