bugGNU Octave - Bugs: bug #54273, Can't access properties of class...


bug #54273: Can't access properties of class in package in function defined in class

Submitted by:  None
Submitted on:  Mon 09 Jul 2018 03:13:03 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Jim Hokanson Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.4.0
Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 11 Mar 2019 10:00:10 PM UTC, comment #4: 

This works for me in Octave 4.4.1 and later versions, closing as fixed. If there are still problems with this feature in current versions of Octave, please file a new bug report.

Mike Miller <mtmiller>
Project Administrator
Tue 17 Jul 2018 01:25:26 PM UTC, comment #3: 

I tend to use it for local helper functions that are only called from within the class. It also reduces indentation while keeping all the code in one file.

Jim Hokanson <jimhokanson>
Tue 17 Jul 2018 11:53:35 AM UTC, comment #2: 

> I have no idea if this is legal syntax...

It's legal syntax in Matlab, at least. I've often seen local functions like this as an alternative to defining static methods, since calling static methods on classes in namespaces can be cumbersome.

Andrew Janke <apjanke>
Tue 10 Jul 2018 12:07:10 AM UTC, comment #1: 

Confirmed. I have no idea if this is legal syntax, but I can confirm that a nested file-scoped function in a class definition file does work normally. It works when myclass.m is directly on the load path, it works when in a @myclass directory, it works when in a +myscope directory, it only fails when inside of a +myscope/@myclass directory.

Mike Miller <mtmiller>
Project Administrator
Mon 09 Jul 2018 03:13:03 AM UTC, original submission:  

I am getting an error about a class definition not being found when trying to access a property of a class object from a function (not method) defined in a class file in a package.

Something like this:


Below all in one file
classdef my_class


function outside_function(obj)
   %obj is instance of my_class
    %Throws an error,
    %class not found: my_class
    my_prop = obj.my_prop



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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jimhokanson (Posted a comment)
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-11 mtmiller StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2018-07-10 mtmiller Priority5 - Normal => 3 - Low
        Operating SystemMicrosoft Windows => Any
    2018-07-10 mtmiller StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.6