bugGNU Octave - Bugs: bug #32060, Accessing OO properties in...

 
 

bug #32060: Accessing OO properties in subfunction of a private class method

Submitter:  Guillaume <gyom>
Submitted:  Wed 05 Jan 2011 03:50:57 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Thu 06 Jan 2011 02:08:06 PM UTC, comment #2: 

It now works for me as well. Thanks.

Guillaume <gyom>
Wed 05 Jan 2011 09:19:13 PM UTC, comment #1: 

I checked in the following changeset:

http://hg.savanna ... /rev/40f311a69417

This change seems to fix the problem for me, so I'm closing this report.

John W. Eaton <jwe>
Group administrator
Wed 05 Jan 2011 03:50:57 PM UTC, original submission:  

Accessing fields of an object should be done directly from within a method (ie not calling subsref/subsasgn): while this is the case for a public class method and for a private class method (see:
https://savannah. ... u.org/bugs/?30909), it is not for a subfunction of a private class method.

This can be reproduced with the following code:

==================== @testclass/testclass.m ====================
function obj = testclass(varargin)
obj = struct('public',1, 'private',0);
obj = class(obj,'testclass');

==================== @testclass/subsref.m ====================
function dat = subsref(obj,subs)
switch subs.type
    case '.'
        switch subs.subs
            case 'public'
                %dat = obj.param;
                dat = param(obj);
            otherwise
                error('err');
        end
    otherwise
        error('err');
end

==================== @testclass/private/param.m ====================
function dat = param(obj)
%dat = obj.public; % direct access => works
dat = param2(obj); % => subfunction calls subsref => crash

function dat = param2(obj)
dat = obj.public; % calls subsref...

========================================
octave> a = testclass;
octave> a.public

results in an infinite loop param<->subsref in Octave, while this works as expected in MATLAB.

Guillaume <gyom>

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  • -email is unavailable- added by gyom
  •  

    Votes

    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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-05 jwe StatusNone Fixed
        Open/ClosedOpen Closed
    2011-01-05 gyom Carbon-Copy- Added highegg

    Back to the top

    Powered by Savane 3.16-2753.
    Corresponding source code