octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55856] subsref called in a subscripted assign


From: Guillaume
Subject: [Octave-bug-tracker] [bug #55856] subsref called in a subscripted assignment operation
Date: Thu, 7 Mar 2019 12:40:38 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

URL:
  <https://savannah.gnu.org/bugs/?55856>

                 Summary: subsref called in a subscripted assignment operation
                 Project: GNU Octave
            Submitted by: gyom
            Submitted on: Thu 07 Mar 2019 05:40:37 PM UTC
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error
                  Status: None
             Assigned to: None
         Originator Name: Guillaume
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

Define the following class with subsref and subsasgn methods


%%% @foo/foo.m
function obj = foo ()
  obj = struct ("store", []);
  obj = class(obj, 'foo');
end



%%% @foo/subsref.m
function val = subsref (obj, S)
  disp ("subsref");
  val = builtin ("subsref", obj.store, S);
end



%%% @foo/subsasgn.m
function obj = subsasgn (obj, S, val)
  disp ("subsasgn");
  obj.store = builtin ("subsasgn", obj.store, S, val);
end


In Matlab:


>> f = foo ();
>> f.a.b = 1;
subsasgn
>> f.a.b
subsref
ans =
     1


In Octave 5.1 or 6.0:


octave:1> f = foo ();
octave:2> f.a.b = 1;
subsref
error: null_matrix cannot be indexed with .
error: called from
    subsref at line 3 column 7
octave:2> f.a = 1;
subsasgn


I don't think that subsref should be called when evaluating "f.a.b = 1;"




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55856>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]