bugGNU Octave - Bugs: bug #54800, Class method invocation errors

 
 

bug #54800: Class method invocation errors

Submitter:  Amro <amro_octave>
Submitted:  Sun 07 Oct 2018 11:07:34 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.4.1 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 08 Oct 2018 06:26:16 PM UTC, comment #2: 

Thanks for your bug report. This is true, this is a side effect of a partial implementation of the destructor method that was made in 4.4. In short, the 'delete' method was never called before version 4.4. In version 4.4, the 'delete' method is now called, but it doesn't really work properly. It's best to avoid it completely until this is fully resolved in a future version of Octave.

I'm going to close this as a duplicate of bug #46497, which is about implementing the delete method.

Mike Miller <mtmiller>
Group Member
Sun 07 Oct 2018 11:14:33 AM UTC, comment #1: 

I just tried the above example in Octave 4.2.2.

All four cases worked without throwing an error, but the destructor is not being called at all! (disp from "delete" is not printed)

Amro <amro_octave>
Sun 07 Oct 2018 11:07:34 AM UTC, original submission:  

I recently upgraded to Octave 4.4.1, and I noticed unexpected errors when invoking a classdef object method.

Take this simple class definition (constructor, destructor, and a method):


classdef MyClass < handle
  methods
    function this = MyClass()
      disp('-- MyClass.MyClass')
    end

    function delete(this)
      disp('-- MyClass.delete')
    end

    function x = func(this)
      disp('-- MyClass.func')
      x = 1;
    end
  end
end


All the following should work for calling the class method:


obj = MyClass();
x = obj.func()
clear obj



obj = MyClass();
x = func(obj)
clear obj



x = MyClass().func()



x = func(MyClass())


But the last two are failing with:
"error: value on right hand side of assignment is undefined"

Interestingly, if I remove the destructor from the class (i.e "delete" function), the last two invocations work again.

In comparison, all the above cases work as expected in MATLAB (dot notation vs. function notation call, as well as using a temporary variable to store the object vs. not)

Amro <amro_octave>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by amro_octave (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 group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-10-08 mtmiller StatusNone Duplicate
        Open/ClosedOpen Closed
        Dependencies- Depends on bugs #46497

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code