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

 
 

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

Submitted by:  Daniel Roeske <dmjr>
Submitted on:  Sat 30 Jan 2016 01:12:41 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

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

All fixed now, closing report.

Rik <rik5>
Project 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>
Project 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

Rik <rik5>
Project 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>
Project 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:

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

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

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

Rik <rik5>
Project 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:

=> works for me.

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

Philip Nienhuis <philipnienhuis>
Project 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:
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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

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

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 03 Feb 2016 11:52:03 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sun 31 Jan 2016 07:08:04 PM UTCphilipnienhuisItem GroupInaccurate Result=>Incorrect Result
      StatusFixed=>Confirmed
      Open/ClosedClosed=>Open
      Release4.0.0=>dev
    Sun 31 Jan 2016 05:30:37 AM UTCrik5StatusWorks For Me=>Fixed
      Open/ClosedOpen=>Closed
    Sat 30 Jan 2016 05:36:15 PM UTCphilipnienhuisStatusNone=>Works For Me
    Sat 30 Jan 2016 01:12:41 AM UTCdmjrCarbon-Copy-=>Added dmjr

    Back to the top


    Powered by Savane 3.1-cleanup1