bugGNU Octave - Bugs: bug #65877, struct field assignment using {:}...

 
 

bug #65877: struct field assignment using {:} produces invalid dimension error

Submitter:  None
Submitted:  Thu 13 Jun 2024 12:35:52 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 23 Jul 2024 09:27:59 PM UTC, comment #2: 

Confirmed as well on development branch.  However this has easy workarounds that are probably clearer code anyways.  I'm lowering the priority.  Because Matlab does accept this construct, I'm changing the Group to "Matlab Compatibility".

The issue is that the code '{:}' is asking the interpreter to look up the variable value for 'A.a', but that variable doesn't exist.  One could, as Matlab has done, check to see that this is an assignment to a non-existent variable and thus suppress the error message and proceed with assignment.  But, it is clearer to just assign a cell array to the desired variable.


A.a = {1};


That is clear as to intent.

Rik <rik5>
Group administrator
Fri 14 Jun 2024 01:45:20 PM UTC, comment #1: 

can confirm with Octave 9.2.0. but i don't think the semicolon has anything to do with it (or did you mean the colon).  Matlab is able to use that syntax for object/field creation. Octave can only use that syntax for an existing field/object:


>> A.a{:}=1
error: invalid dimension inquiry of a non-existent value

>> c = {99}
c =
{
  [1,1] = 99
}

>> A.a=c
A =

  scalar structure containing the fields:

    a =
    {
      [1,1] = 99
    }


>> A.a{:}=1
A =

  scalar structure containing the fields:

    a =
    {
      [1,1] = 1
    }


>> B.c = 1
B =

  scalar structure containing the fields:

    c = 1

>> B.a{:}=1
error: invalid dimension inquiry of a non-existent value

>> B.a(:)=2
B =

  scalar structure containing the fields:

    c = 1
    a = [](0x0)



Nicholas Jankowski <nrjank>
Group Member
Thu 13 Jun 2024 12:35:52 PM UTC, original submission:  

In Octave, from a non existing variable A:


octave> A.a{:} = 1;
error: invalid dimension inquiry of a non-existent value


In Matlab:


>> A.a{:} = 1;
>> A
A =
  struct with fields:
    a: {[1]}


Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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 nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Updated 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-07-23 rik5 Priority5 - Normal 3 - Low
        Item GroupUnexpected Error or Warning Matlab Compatibility
    2024-06-14 nrjank StatusNone Confirmed
        Summarystruct field setting using semicolon struct field assignment using {:} produces invalid dimension error
    2024-06-13 jwe Item GroupMatlab Compatibility Unexpected Error or Warning

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code