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

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

[Octave-bug-tracker] [bug #60723] subsagn raise error on .-indexing for


From: Fernando
Subject: [Octave-bug-tracker] [bug #60723] subsagn raise error on .-indexing for table with subsref/subsasgn defined
Date: Fri, 4 Jun 2021 13:04:14 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0

Follow-up Comment #3, bug #60723 (project octave):

The problem is caused by the user-defined 'numel' function, and the different
way Matlab and octave treat that function.

I have checked that the issue can be reproduced with this simple class
definition:


classdef bug60723 < handle
  properties
    c = 3;
  end
  methods
    function n = numel (this)
      n =6;
    end 
  end
end


In Matlab:

>> x=bug60723();
>> x.c=20;
>> x.c
ans =
    20


While in octave (current development version):

>> x=bug60723();
>> x.c=20;
error: invalid dot name structure assignment because the structure array is
empty.  Specify a subscript on the structure array to resolve.
>> x.c
ans = 3


In a statement like "x.c=20", both Matlab and octave have to check that x.c
evaluates to a single "object" or left-value. If, e.g. x were a struct array:

>> x=struct("c",{1,2,3});

Then the sentence "x.c=20" would be incorrect (both in Matlab and octave),
because x.c evaluates to a list of 3 different left-values.

To check the number of left-values corresponding to x.c, octave calls the
function numel on the object x. This should return 1, but because it has been
redefined it returns 6, which causes the error.

To do the same thing, Matlab does not call numel, but uses the function
numArgumentsFromSubscript instead, which can also be redefined by the user.

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Mensaje enviado vía Savannah
  https://savannah.gnu.org/




reply via email to

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