bugGNU Octave - Bugs: bug #63186, function handle in constructor of...

 
 

bug #63186: function handle in constructor of a class

Submitter:  Guillaume <gyom>
Submitted:  Sat 08 Oct 2022 08:29:28 PM UTC
   
 
Category:  Classdef Severity:  2 - Minor
Priority:  1 - Later Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 30 Jan 2024 11:10:57 PM UTC, comment #1: 

I can reproduce the behavior, but this feels like an extreme corner case unlikely to show up in regular code.  As you pointed out, there is a workaround by using the name of the class rather than a handle to the class constructor.

Rik <rik5>
Group administrator
Sat 08 Oct 2022 08:29:28 PM UTC, original submission:  

If a function handle of a class is used in its constructor, the class seems to be broken afterwards. I attach a slightly contrived example that reproduces the issue:


>> s = classbug ("gnu octave");
>> s = classbug ({"gnu octave"});
>> s = classbug ("gnu octave");
error: no indexing!
error: called from
    subsref at line 17 column 7
    classbug at line 10 column 18


As you can see, after executing the second statement (that makes use of a function handle to the class), the first statement doesn't execute properly any more, with subsref() being called inappropriately. It works if "cellfun ('classbug',...)" is used instead of "cellfun (@classbug,...)".

Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53817:  classbug.m added by gyom (486B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by gyom (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-30 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 1 - Later
        StatusNone Confirmed
    2024-01-23 mmuetzel CategoryInterpreter Classdef
    2022-10-08 gyom Attached File- Added classbug.m, #53817

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code