bugGNU Octave - Bugs: bug #47021, Calling nargin for scripts returns...

 
 

bug #47021: Calling nargin for scripts returns wrong error message

Submitter:  Daniel Roeske <dmjr>
Submitted:  Sat 30 Jan 2016 01:12:41 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 03 Feb 2016 11:52:03 PM UTC, comment #8: 

All fixed now, closing report.

Rik <rik5>
Group administrator
Wed 03 Feb 2016 04:57:47 AM UTC, comment #7: 

Oops, I didn't think about that one.  Thanks for pointing that out.  I pushed this fix so nargin and nargout should behave similarly:

http://hg.savannah.gnu.org/hgweb/octave/rev/a428c6ba6334

John W. Eaton <jwe>
Group administrator
Wed 03 Feb 2016 12:39:33 AM UTC, comment #6: 

@jwe: The nargout function in the same file should probably get the same treatment as nargin.  See ov-usr-fcn.cc:966


error ("nargout: nargout information not available for built-in functions.");


Rik <rik5>
Group administrator
Tue 02 Feb 2016 11:37:00 PM UTC, comment #5: 

I checked in the the following changeset to improve the error message:

http://hg.savannah.gnu.org/hgweb/octave/rev/8bec8855e9ce


John W. Eaton <jwe>
Group administrator
Sun 31 Jan 2016 07:08:04 PM UTC, comment #4: 

Reopening.

On reading more closely (sorry Daniel for noting only now; good that you hinted again in comment #2) I can confirm this.

In Octave-4.1.0+, with a script g.m s follows:

## This is a scipt file
printf ("This is g.m\n" );


I get:

>> g
This is g.m
>> nargin (g)
error: invalid call to script /home/philip/tmp/g.m
>> nargin (@g)
error: nargin: nargin information not available for built-in functions
>>


Admittedly script files (not function files) aren't supposed to have input or output arguments; but Octave's reaction (interpreting "g" as a built-in function) is beside the point.


Philip Nienhuis <philipnienhuis>
Group Member
Sun 31 Jan 2016 05:30:37 AM UTC, comment #3: 

This seems to have been fixed.  I created a file g.m with the contents


function y = g (x)
  y = pi;
endfunction


When I run with the 4.0.1rc-3 release candidate there is no error and the number of inputs is returned correctly.


nargin (@g)
ans =  1


Upgrade to 4.0.1 when it becomes available, or build from source.  Either way will get you the fix.


Rik <rik5>
Group administrator
Sat 30 Jan 2016 05:41:16 PM UTC, comment #2: 

It's about scripts, not about functions. Try it with a script g.

Anonymous
Sat 30 Jan 2016 05:36:15 PM UTC, comment #1: 

Trying in Octave-4.1.0+ (development version) with:

function [retval] = g ()
  printf ("This is g\n");
  retval = "a";
endfunction

I get:

>> nargin (@g)
ans = 0


=> works for me.

Whatever bug there was, it seems to have been fixed in the dev version.


Philip Nienhuis <philipnienhuis>
Group Member
Sat 30 Jan 2016 01:12:41 AM UTC, original submission:  

Having a script g defined, calling nargin results in an unexpected error message:

>> nargin(@g)
error: nargin: nargin information not available for built-in functions

Receiving an error message might be expected, but g is definitely not a built-in function.

Daniel Roeske <dmjr>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-03 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-01-31 philipnienhuis Item GroupInaccurate Result Incorrect Result
        StatusFixed Confirmed
        Open/ClosedClosed Open
        Release4.0.0 dev
    2016-01-31 rik5 StatusWorks For Me Fixed
        Open/ClosedOpen Closed
    2016-01-30 philipnienhuis StatusNone Works For Me
    2016-01-30 dmjr Carbon-Copy- Added dmjr

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code