bugGNU Octave - Bugs: bug #56318, deal: invalid assignment to...


bug #56318: deal: invalid assignment to cs-list outside multiple assignment

Submitter:  Guillaume <gyom>
Submitted:  Mon 13 May 2019 01:49:53 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Mon 13 May 2019 04:36:04 PM UTC, comment #1: 

Confirmed.  Changing item group to "Matlab Compatibility" since Octave does allow for multiple assignment, but with different semantics from Matlab.

Either of these scalar assignments work in Octave or Matlab.

A = struct ('a', 1);
[A(:).a] = 0
[A(:).a] = deal (3)

Similarlay, when the struct array is not scalar, then scalar assignment fails but deal() works.

A(2).a = pi;
[A(:).a] = 45;         % This fails in Octave and Matlab
[A(:).a] = deal (45);  % This works in Octave and Matlab

However, when the field does not exist, Octave produces an error, while Matlab goes ahead and creates the new field, and then performs assignment.  This is the original case

A = struct ('a', 1);
[A(:).b] = deal (0);

If you use the debugger you can step through the deal.m function and find that it returns a scalar, cell array.  For the code above, the interpreter is seeing

[A(:).b] = {0};

In most cases of assignment, the left-hand side has a fixed size, or it is a new variable and so size is unimportant.  For example, the assignment

[d(:)] = 5

succeeds presumably because the interpreter detects that d does not exist and so there doesn't need to be any size checks.

Adding jwe since he is the only one who knows, probably, where to begin on this one.

Rik <rik5>
Group administrator
Mon 13 May 2019 01:49:53 PM UTC, original submission:  

The following runs without error in Matlab but not in Octave:

>> A = struct ('a', 1);
>> [A(:).b] = deal (0);
error: invalid assignment to cs-list outside multiple assignment

Guillaume <gyom>


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

Attach Files:

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 gyom (Submitted 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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-13 rik5 Item GroupUnexpected Error or Warning Matlab Compatibility
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-a854.
    Corresponding source code