bugGNU Octave - Bugs: bug #57966, Functions in current folder...

 
 

bug #57966: Functions in current folder shoadow functions on path

Submitter:  None
Submitted:  Sat 07 Mar 2020 08:22:07 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 07 Mar 2020 07:06:09 PM UTC, comment #1: 

This is correct behavior, and is compatible with Matlab.

Mike Miller <mtmiller>
Group Member
Sat 07 Mar 2020 08:22:07 AM UTC, original submission:  

Consider the following folder structure:


\---currentfolder
    |   A.m
    |   C.m
    |
    \---path1
            B.m
            C.m


A folder named "currentfolder" contains a subfolder named "path1" and two other files "A.m" and "C.m". "path1" contains two files "B.m" and "C.m".


%currentfolder\A.m

function A
  B();
end



%currentfolder\C.m

function C
  disp('function in currentfolder');
end



%path1\B.m

function B
  C();
end



%path1\C.m

function C
  disp('function in path1');
end


cd to "currentfolder" and add "path1" to the path:

> cd ('c:\currentfolder')
> addpath('c:\currentfolder\path1')


and call "A"

> A();


It shows "function in currentfolder" but I think the correct answer should be "function in path1".
It means that a function in the current folder "currentfolder\C.m" that has the same name as a function in the path "path1\C.m" can hide its name and prevent other functions on the path "path1\B.m" to see "path1\C.m".

I'm not sure but I think it may be a MATLAB incompatibility.

I also attached a zip file of the folder structure.

Thanks.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #48560:  currentfolder.zip added by None (1KiB - application/x-stuffit)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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

Date Changed by Updated Field Previous Value => Replaced by
2020-03-07 mtmiller StatusNone Invalid / Not an Octave Bug
    Open/ClosedOpen Closed
2020-03-07 None Attached File- Added currentfolder.zip, #48560

Back to the top

Powered by Savane 3.13-02a9.
Corresponding source code