bugGNU Octave - Bugs: bug #60791, classdef subsasgn / subsref called...


bug #60791: classdef subsasgn / subsref called incorrectly

Submitted by:  Ray Zimmerman <rdzman>
Submitted on:  Thu 17 Jun 2021 05:37:07 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.2.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.


Thu 17 Jun 2021 07:47:41 PM UTC, comment #1: 

FWIW, I also just noticed that if you create a handle to the constructor before calling it the first time, that also resolves the problem.

Ray Zimmerman <rdzman>
Thu 17 Jun 2021 05:37:07 PM UTC, original submission:  

The subsasgn and subsref methods of a classdef object can be called from within methods of the class by saving a handle to the constructor.

The following example should never call the class's subsasgn method, but it does call it on the second call to the constructor.

classdef rdz_table
        function obj = rdz_table(val)
            obj.p = val;
        function obj = subsasgn(obj, s, b)

T1 = rdz_table(1);
cls = @rdz_table;
T2 = rdz_table(2);

Commenting out the line that assigns cls makes the problem go away. I believe it also affects subsref, since the following results in a mistaken call to subsasgn which subsequently mistakenly calls subsref resulting in a recursion limit.

pkg load tablicious
T1 = table(1);
cls = @table;
T2 = table(2);

This example above works fine on 5.2.0. FYI, I've only tested this on macOS, but I suspect it applies to all OSs.

Ray Zimmerman <rdzman>


(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 rdzman (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.




    No changes have been made to this item

    Back to the top

    Powered by Savane 3.6