bugGNU Octave - Bugs: bug #55223, can't subsasgn with 2-level index...

 
 

bug #55223: can't subsasgn with 2-level index (curly braces + parentheses) with classdef handle

Submitted by:  Sébastien Villemot <svillemot>
Submitted on:  Fri 14 Dec 2018 10:01:53 AM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  5.1.0 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

( Jump to the original submission)

Thu 21 Feb 2019 02:15:51 PM UTC, comment #6: 

I pushed an overhauled classdef test to stable:

https://hg.savannah.gnu.org/hgweb/octave/rev/ad71c8d87cff

Again, if there are strong objections about applying it just before the 5.1 release I or jwe could delay it, too.

Kai Torben Ohlhus <siko1056>
Project Member
Thu 21 Feb 2019 07:19:31 AM UTC, comment #5: 

I pushed this changeset to stable:

http://hg.savannah.gnu.org/hgweb/octave/rev/17d806c3f7cd

If there are strong objections about applying it just before the 5.1 release I could delay it.

John W. Eaton <jwe>
Project Administrator
Sun 13 Jan 2019 12:03:11 AM UTC, comment #4: 

whoops..
i came across an issue which i think is related. I tried in Windows/4.4.0 and Ubuntu 4.2.2

For class:

classdef ASB < handle
  methods
    function varargout = subsref(self,s)
    end
    function self = subsasgn(self,s,v)
    end
  end
end

Non of the following 2-or-more level indizes/subsref assigns work. Neither subsref nor subsasign are called. In Matlab subsasign is called.

a.x.x = 1; %  subsref: unknown method or property: x
a.x(1) = 1; %  subsref: unknown method or property: x
a{1}.w = 1; % object cannot be indexed with `{'

a(1).h.e.l.l.o = 1 % works!

 

Jonas

Anonymous
Sun 13 Jan 2019 12:00:56 AM UTC, comment #3: 

Hi
i came across an issue which i think is related. I tried in Windows/4.4.0 and Ubuntu 4.2.2

For class:

Anonymous
Thu 10 Jan 2019 11:18:10 PM UTC, comment #2: 

This patch applies cleanly to the stable branch and builds, but I can't say whether this correct or whether it breaks any previous classdef use cases. It works for all of my own test cases.

Since I haven't looked at the classdef code in a long time, I'd prefer confirmation from another reviewer.

Mike Miller <mtmiller>
Project Administrator
Mon 17 Dec 2018 03:48:07 PM UTC, comment #1: 

I attach a changeset that fixes the issue for me (along with a testcase).

(file #45680)

Sébastien Villemot <svillemot>
Fri 14 Dec 2018 10:01:53 AM UTC, original submission:  

Hi,

With a classdef handle, it is impossible to implement a syntax such as:

obj{x}(y) = z;

Even with a proper subsasgn method overload, Octave errors out:

error: object cannot be indexed with `{'

I attach a minimal example.

Below is a backtrace (with mercurial tip) just before the error is printed:

#0  cdef_object_scalar::subsref (this=0x555555bd5210, type="{",
    idx=std::__cxx11::list = {...}, nargout=1, skip=@0x7fffffffb458: 0,
    context=..., auto_add=true) at libinterp/octave-value/ov-classdef.cc:1462
#1  0x00007ffff7232ece in cdef_object::subsref (auto_add=<optimized out>,
    context=..., skip=@0x7fffffffb458: 0, nargout=1,
    idx=std::__cxx11::list = {...}, type="{", this=0x55555593f600)
    at ./libinterp/octave-value/ov-classdef.h:284
#2  octave_classdef::subsref (this=0x55555593f5f0, type="{",
    idx=std::__cxx11::list = {...}, auto_add=<optimized out>)
    at libinterp/octave-value/ov-classdef.cc:910
#3  0x00007ffff73d312e in octave_value::subsref (auto_add=true,
    idx=std::__cxx11::list = {...}, type="{", this=0x7fffffffb670)
    at ./libinterp/octave-value/ov.h:425
#4  octave::tree_index_expression::lvalue (this=0x55555596dc20, tw=...)
    at libinterp/parse-tree/pt-idx.cc:227
#5  0x00007ffff73c133f in octave::tree_evaluator::visit_simple_assignment (
    this=0x5555557cf228, expr=...) at libinterp/parse-tree/pt-eval.cc:2667
#6  0x00007ffff7259452 in octave::tree_evaluator::evaluate (this=0x5555557cf228,
    expr=0x55555593eca0, nargout=<optimized out>)
    at libinterp/parse-tree/pt-eval.h:312
#7  0x00007ffff73bdf1f in octave::tree_evaluator::visit_statement (
    this=0x5555557cf228, stmt=...) at libinterp/parse-tree/pt-eval.cc:2775
#8  0x00007ffff73b3c90 in octave::tree_statement::accept (tw=...,
    this=0x555555bbc090) at libinterp/parse-tree/pt-stmt.h:119
#9  octave::tree_evaluator::visit_statement_list (this=0x5555557cf228, lst=...)
    at libinterp/parse-tree/pt-eval.cc:2844
#10 0x00007ffff73b7493 in octave::tree_statement_list::accept (tw=...,
    this=0x555555a0f7c0) at libinterp/parse-tree/pt-stmt.h:194
#11 octave::tree_evaluator::execute_user_script (this=this@entry=0x5555557cf228,
    user_script=..., nargout=nargout@entry=0, args=...)
    at libinterp/parse-tree/pt-eval.cc:1512

Sébastien Villemot <svillemot>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #45680:  bug55223.patch added by svillemot (4KiB - text/x-patch)
file #45649:  bug-classdef-subsasgn.tar.gz added by svillemot (495B - application/gzip)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-10 rik5 StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
        Releasedev => 5.1.0
    2019-02-21 jwe StatusPatch Reviewed => Ready For Test
    2019-02-12 siko1056 Dependencies- => bugs #54783 is dependent
    2019-01-10 mtmiller StatusNone => Patch Reviewed
    2018-12-17 svillemot Attached File- => Added bug55223.patch, #45680
    2018-12-14 svillemot Attached File- => Added bug-classdef-subsasgn.tar.gz, #45649

    Back to the top


    Powered by Savane 3.5