bugGNU Octave - Bugs: bug #62077, classdef: cannot fully recover...


bug #62077: classdef: cannot fully recover cleared object variable

Submitter:  Kai Torben Ohlhus <siko1056>
Submitted:  Fri 18 Feb 2022 09:55:44 AM UTC
Category:  Classdef Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 18 Feb 2022 09:55:44 AM UTC, original submission:  

Given the class

classdef bad_class
  methods (Access = 'private')
    function foo1(obj)
      disp ('call foo1');
    function foo2(obj)
      disp ('call foo2');
      clear all;
      obj = evalin ('caller', 'obj');
      disp ('     clear all');
      obj.foo1 ();
    function foo3(obj)

In member function `foo2` the command `clear all` clears all variables in the current scope.  This is conform with Matlab R2021a.

In Matlab one can recover the lost variable as described in `foo2`.  In Octave 6.4.0, 7, and 8 the output is:

call foo2
     clear all
error: subsref: method 'foo1' has private access and cannot be run in this context
error: called from
    foo2 at line 11 column 7
    foo3 at line 16 column 7

A workaround is declaring everything as "public".  Same problem with "protected"

Similar to bug #56953.

Kai Torben Ohlhus <siko1056>
Group Member


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

Attach Files:

No files currently attached


   bug dependencies.

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by siko1056 (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
    2022-03-04 mmuetzel Carbon-CopyRemoved 102357 -
    2022-03-04 mmuetzel CategoryInterpreter Classdef
    2022-02-18 siko1056 Dependencies- Depends on bugs #56953

    Back to the top

    Powered by Savane 3.12