bugGNU Octave - Bugs: bug #43299, anonymous function arguments may...

 
 

bug #43299: anonymous function arguments may be shadowed by function names

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Thu 25 Sep 2014 12:23:34 PM 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.

 

Wed 25 Nov 2015 03:49:36 PM UTC, comment #2:

Agree, working now.

Mike Miller <mtmiller>
Project Administrator
Wed 25 Nov 2015 12:46:28 AM UTC, comment #1:

@Mike: I think this bug may have been fixed somewhere in the last year. I tried the three examples you posted and they all work. This is with cset 74cc8ae4e2b0 from 11/24/15.

Rik <rik5>
Project Administrator
Thu 25 Sep 2014 12:23:34 PM UTC, original submission:

This seems to be a subtle bug in the way that names are resolved in the definition of an anonymous function. If the name of an anonymous function argument is also the name of a function (command-line, m-file, or oct-file), the name may resolve to the function rather than the argument.

Some examples:

This seems to work fine even if x is defined as a function.

This anon function definition attempts to resolve x as a function first, and only if it doesn't exist does it work as the argument to the anon function. The name lookup happens when the function is defined, not when it is called. So if I create an invalid oct-file for example,

the error is thrown when the function is being defined.

This can break code in Octave itself if an anonymous function is defined with an arg like "x" and the user creates a function also named "x". See for example bug #43237.

According to Ben, Matlab correctly handles this case, the anonymous function argument name always takes precedence.

Mike Miller <mtmiller>
Project Administrator

 

(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

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (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
    Wed 25 Nov 2015 03:49:36 PM UTCmtmillerStatusWorks For Me=>Fixed
      Open/ClosedOpen=>Closed
    Wed 25 Nov 2015 12:46:28 AM UTCrik5StatusNone=>Works For Me
    Thu 25 Sep 2014 12:25:13 PM UTCmtmillerDependencies-=>bugs #43237 is dependent

    Back to the top


    Powered by Savane 3.1-cleanup1