Unmatched dimensions can combine without error in some circumstances #24

Closed
opened 2025-10-13 23:00:11 +00:00 by UserCurt · 1 comment
UserCurt commented 2025-10-13 23:00:11 +00:00 (Migrated from codeberg.org)

If matching multiple fields of various sizes, the sizes can mesh in such a way that the result could be valid. This behavior is inconsistent depending on the orientation of the mismatch.

>> S = struct(A=1, B=2, C=3, D=[4 5 6]);
>> mpath.get(S, ["/A", "/B", "/C"; "/D", missing, missing])
Error using cat
Dimensions of arrays being concatenated are not consistent.

Error in mpath.external.catcell (line 87)
      Rnew{index} = cat(d, R{ind{:}});
                    ^^^^^^^^^^^^^^^^^
Error in mpath.Pointer/get (line 148)
      result = mpath.external.catcell(result,'all');
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in mpath.get (line 66)
  result = mp.get(data, varargin{:});
           ^^^^^^^^^^^^^^^^^^^^^^^^^
>> S = struct(A=1, B=2, C=3, D=[4;5;6]);
>> mpath.get(S, ["/A", missing; "/B", missing; "/C", "/D"])

ans =

     1     4
     2     5
     3     6

Expected behavior is to get an error in both cases from incompatible sizes.

This is an upstream bug with catcell (no repository currently).

If matching multiple fields of various sizes, the sizes can mesh in such a way that the result could be valid. This behavior is inconsistent depending on the orientation of the mismatch. ```matlab >> S = struct(A=1, B=2, C=3, D=[4 5 6]); >> mpath.get(S, ["/A", "/B", "/C"; "/D", missing, missing]) Error using cat Dimensions of arrays being concatenated are not consistent. Error in mpath.external.catcell (line 87) Rnew{index} = cat(d, R{ind{:}}); ^^^^^^^^^^^^^^^^^ Error in mpath.Pointer/get (line 148) result = mpath.external.catcell(result,'all'); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error in mpath.get (line 66) result = mp.get(data, varargin{:}); ^^^^^^^^^^^^^^^^^^^^^^^^^ ``` ```matlab >> S = struct(A=1, B=2, C=3, D=[4;5;6]); >> mpath.get(S, ["/A", missing; "/B", missing; "/C", "/D"]) ans = 1 4 2 5 3 6 ``` Expected behavior is to get an error in both cases from incompatible sizes. This is an upstream bug with `catcell` (no repository currently).
Owner

Fixed by commit d38f4ab. Validation is performed before concatenation in catcell now.

Fixed by commit `d38f4ab`. Validation is performed before concatenation in `catcell` now.
Sign in to join this conversation.
No description provided.