bugGNU Octave - Bugs: bug #54941, interpreter cannot find methods in...

 
 

bug #54941: interpreter cannot find methods in files of classdefs in packages

Submitter:  A.R. Burgers <arb>
Submitted:  Fri 02 Nov 2018 06:55:06 PM UTC
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Thu 07 Mar 2019 11:18:34 PM UTC, comment #3: 

There have been a few improvements to namespaces and classdef classes, but this is still a problem on the Octave 6 development branch.

ver = 6.0.0
hg_id = 29bcb31edd76
ans =  3
ans =  3.1416
ans =  3
error: subsref: unknown method or property: report_pi
error: called from
    test_Myclass at line 10 column 1

Mike Miller <mtmiller>
Project Administrator
Sun 04 Nov 2018 09:39:11 PM UTC, comment #2: 

adding a prototype in +pckg/Myclass.m for report_pi helps, but shouldn't be necessary I guess:

classdef Myclass
   methods (Static)
      output = staticFunc1(arg1,arg2)
   end
   methods
     val = report_pi(obj)
   end
end

The discussion in https://savannah.gnu.org/bugs/?45444 is on functions in a private subdir. But that is not necessary with classdefs where you can declare the prototype of the private functions in a method (Access = private) block, as per https://nl.mathworks.com/help/matlab/matlab_oop/methods-in-separate-files.html

I don't think any of the patches and tests proposed there by amro made it to the mercurial repository.

A.R. Burgers <arb>
Sat 03 Nov 2018 09:14:30 AM UTC, comment #1: 

Is this one of the many cases reported in bug #45444?

Guillaume <gyom>
Fri 02 Nov 2018 06:55:06 PM UTC, original submission:  

consider the hierarchy below with the same functions and methods and definition for Myclass and pckg.Myclass.

./@Myclass/report_pi.m
./@Myclass/Myclass.m
./@Myclass/staticFunc1.m
./+pckg/@Myclass/report_pi.m
./+pckg/@Myclass/Myclass.m
./+pckg/@Myclass/staticFunc1.m
./test_Myclass.m

Executing test_Myclass.m with octave (stable and dev) gives this error message

ver = 4.4.1
hg_id = 7a7c31b93216+
ans =  3
ans =  3.1416
ans =  3
error: subsref: unknown method or property: report_pi

the report_pi method is not found in package +pckg.
Remarkably the static function is found in both cases.
The function definitions are below:

function val = report_pi(obj)
  val = pi;
end

function output = staticFunc1(arg1,arg2)
  output = arg1 + arg2;
end

classdef Myclass
   methods (Static)
      output = staticFunc1(arg1,arg2)
   end
end

% save script as test_Myclass.m
ver = version
hg_id = __octave_config_info__.hg_id
a = Myclass;
a.staticFunc1(1,2)
a.report_pi

b = pckg.Myclass;
b.staticFunc1(1,2)
b.report_pi

A.R. Burgers <arb>

 

(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

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by arb (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 project members can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-21 mtmiller Dependencies- bugs #50452 is dependent
    2019-03-07 mtmiller StatusNone Confirmed
        Release4.4.1 dev

    Back to the top


    Powered by Savane 3.9