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

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

[Octave-bug-tracker] [bug #65876] error retrieving data from struct valu


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #65876] error retrieving data from struct values in containers.Maps
Date: Thu, 13 Jun 2024 11:59:36 -0400 (EDT)

Follow-up Comment #5, bug #65876 (group octave):

I ended up at the same code block.

I'm guessing this block is trying to handle indexing expressions like the
following:

a(1).b = 1;
a(2).b = 2;
a(3).b = 3;

c = [a([1,3]).b];


Where the expression inside the bracket in the last line returns a
comma-separated list. (Of course, that example doesn't involve overloaded
subsref methods. But I hope you get the idea.)

Afaict, the original change that added logic for these kinds of expressions
might have been:
https://hg.savannah.gnu.org/hgweb/octave/rev/a18897e4c7b5

The attached patch fixes the issue for me by not interpreting character arrays
as valid indices.

However, that is probably not correct in every case. Character arrays *can* be
used as indexing expressions. E.g.:

>> a('ab') = 1;
>> size(a)
ans =
     1    98
>> sum(a)
ans =
     2


Another example on Matlab R2024a:

>> clear a
>> a('a').b = 1;
>> a('b').b = 2;
>> a('ab').b
ans =
     1

ans =
     2


A slightly changed version of the original example doesn't interpret the
character vector as indices:

>> cm = containers.Map;
>> data.x = 1;
>> cm('foo') = data;
>> cm('foo').x
ans =
     1


I'm not sure how to reliably detect at that point that the expression inside
the parenthesis won't lead to a comma-separated list being required as the
result...


(file #56160)

    _______________________________________________________

Additional Item Attachment:

File name: bug65876-classdef-subsref-keys.patch Size: 3KiB
   
<https://file.savannah.gnu.org/file/bug65876-classdef-subsref-keys.patch?file_id=56160>


    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://git.savannah.nongnu.org/cgit/administration/savane.git/snapshot/savane-e8ed2bd839b51542fcb639f6290b2ad8f231f49e.tar.gz


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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