bugGNU Octave - Bugs: bug #35448, incorrect function handle...

 
 

bug #35448: incorrect function handle resolution in recursive function call

Submitter:  Ben Abbott <bpabbott>
Submitted:  Sat 04 Feb 2012 07:23:14 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Ben Abbott 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

Sun 05 Feb 2012 08:42:11 PM UTC, comment #6: 

Oops.  I checked it in.

John W. Eaton <jwe>
Group administrator
Sun 05 Feb 2012 08:37:15 PM UTC, comment #5: 

John, did you forget to push parse-private.h ?

Ben Abbott <bpabbott>
Group Member
Sun 05 Feb 2012 07:34:37 PM UTC, comment #4: 

I checked in the following changeset.  This change appears to fix the problem for me, so I'm closing this report.

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

John W. Eaton <jwe>
Group administrator
Sun 05 Feb 2012 06:21:40 PM UTC, comment #3: 

The examples use function handles, but there are no anonymous functions involved, so I changed the summary.

John W. Eaton <jwe>
Group administrator
Sat 04 Feb 2012 09:00:44 PM UTC, comment #2: 

Opps. that should be "fB" not "FB".

Ben Abbott <bpabbott>
Group Member
Sat 04 Feb 2012 08:43:02 PM UTC, comment #1: 

In case it is important, if @fB is replaced with "FB" in fA.m, the error does not occur.

Ben Abbott <bpabbott>
Group Member
Sat 04 Feb 2012 07:23:14 PM UTC, original submission:  

With each function in its own m-file


# fA.m
function y = fA (x, f)
  global gfun
  if nargin < 2
    y = fA (x, gfun);
  else
    w = feval (f, x)
    y = feval (@fB, w);
  endif
endfunction



# fB.m
function y = fB (x)
  y = x;
endfunction



# fC.m
function y = fC (x)
  y = x;
endfunction


Running the script below, or typing the commands at the prompt produces the proper result.


clear all
global gfun
gfun = @fB;
y = fA (e)


The proper result is


foo
w =  2.7183
y =  2.7183


The modified version below (@fC instead of @fB) throws an error.


clear all
global gfun
gfun = @fC;
y = fA (e)


The error is


w =  2.7183
error: `w' undefined near line 7 column 21
error: evaluating argument list element number 2


Notice that in fA.m `w' evaluates to the proper result.

fB and fC are intentionally identical, and there is no problem if the global variable isn't used.

I've attached the files. foo.m is a script that runs the working and failing example.

Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #24981:  Archive.zip added by bpabbott (780B - application/zip)

 

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 bpabbott (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
    2012-02-05 jwe StatusNone Fixed
        Open/ClosedOpen Closed
    2012-02-05 jwe Summaryparser problems with nested anonymous functions incorrect function handle resolution in recursive function call
    2012-02-04 bpabbott Attached File- Added Archive.zip, #24981

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code