bugGNU Octave - Bugs: bug #33605, concatenation of struct with empty...

 
 

bug #33605: concatenation of struct with empty character vector fails

Submitter:  John W. Eaton <jwe>
Submitted:  Mon 20 Jun 2011 05:04:19 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  1 - Later Item Group:  WTF, Matlab?!?
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 18 Apr 2023 02:46:42 PM UTC, comment #10: 

In 8.2.1:


octave:13> s.a = 1; s.b = 2;
octave:14> ["", s]
error: octave_base_value::convert_to_str_internal (): wrong type argument 'scalar struct'
octave:15> ['', s]
error: octave_base_value::convert_to_str_internal (): wrong type argument 'scalar struct'
octave:16> [[],s]
ans =

  scalar structure containing the fields:

    a = 1
    b = 2

octave:17> version
ans = 8.2.1


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Tue 18 Apr 2023 02:41:35 PM UTC, comment #9: 

updating that this incompatibility still exists in v8.1.0.  as of matlab 2023a, the comment #2 inputs produces the same results, with empty char vectors concatenating, but empty strings producing an error.


Nicholas Jankowski <nrjank>
Group Member
Wed 17 Nov 2021 08:59:35 PM UTC, comment #8: 

Just updating that this is still around in 6.4.0. 

I suspect the fact that strings fail in Matlab (still fails in v2021a) is just part of Matlab being sloppy about consistency with string class implementation, as we've seen pop up elsewhere. Wouldn't surprise me to see ["",s] suddenly start working in a future version. but since we don't currently have a string class, it's probably not a huge point of difference for Octave.

Nicholas Jankowski <nrjank>
Group Member
Tue 04 Jun 2019 01:44:53 AM UTC, comment #7: 

This increasingly looks like Matlab silliness.  While testing in Matlab 2019, I found that you can concatenate empty character vectors with a struct, but you can't concatenate empty strings.  This works


s.a = 1; s.b = 2;
['', s]


But, this fails


s.a = 1; s.b = 2;
["", s]


I have re-titled the report to be accurate that it is not strings, but only character vectors that can be concatenated.  I've lowered the priority even further to 1.

Rik <rik5>
Group administrator
Thu 08 Dec 2016 04:14:29 AM UTC, comment #6: 

still exists in 4.2.0. Octave errors on 4 empty string examples in original submission, while Matlab 2016b produces:


>> [[],s]
ans =
  struct with fields:

    a: 1
    b: 2


Nicholas Jankowski <nrjank>
Group Member
Wed 31 Dec 2014 08:08:11 PM UTC, comment #5: 

No, I wasn't going to close it; Just thought that it should be correctly labeled.  I'm going to lower the priority as well since someone could pay to have this fixed, but the current behavior doesn't bother me enough to get out of bed and on to the computer.

Rik <rik5>
Group administrator
Wed 31 Dec 2014 07:50:32 PM UTC, comment #4: 

I changed the category.  I wouldn't close this report though, it's sitll a valid Matlab incompatibility.  I guess the rule is just to check whether something is empty and if so skip it in the concatenation.  I don't know for sure though.

John W. Eaton <jwe>
Group administrator
Wed 31 Dec 2014 07:28:55 PM UTC, comment #3: 

Should this bug be classified as Incorrect Result, or Matlab Compatibility?  It seems utterly weird to try and concatenate a string with a struct and I would think the correct behavior is to error out.

Rik <rik5>
Group administrator
Sun 16 Mar 2014 06:54:11 PM UTC, comment #2: 

The issue is still present (3/16/14).  Concatenation of an empty string value, '' or "", with a struct results in an error.


s.a = 1; s.b = 2;
['', s]
["", s]
[s, '']
[s, ""]



[s, '']
error: octave_base_value::convert_to_str_internal (): wrong type argument 'scalar struct'


Rik <rik5>
Group administrator
Sat 22 Jun 2013 02:21:52 AM UTC, comment #1: 

This is an old report, from 2011, but the issue is still there (6/21/13).  Since the parser has undergone significant work, can we make a call about whether we should support promoting empty strings to nulls for concatenations with structs?

Rik <rik5>
Group administrator
Mon 20 Jun 2011 05:04:19 PM UTC, original submission:  

The following should all work


s.a = 1; s.b = 2;
[[], s]
['', s]
["", s]
[s, []]
[s, '']
[s, ""]


but the character string versions fail on invalid conversions.

Should we be treating literal null matrices specially in tree_matrix::rvalue1 in pt-mat.cc?  Because of the way that function handles initial empty values, it seems that functions like
oct_catop_matrix_struct in op-struct.cc are not called in all cases.  Or maybe they are never called?  In what cases are they be called?  Should they be called for all empty value cases?  Just for non-literal empty matrices?  At this point, I'm obviously not sure what the right fix is...

John W. Eaton <jwe>
Group administrator

 

(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 dasergatskov (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-04 rik5 Priority3 - Low 1 - Later
        Summaryconcatenation of struct with empty string fails concatenation of struct with empty character vector fails
    2014-12-31 rik5 Priority5 - Normal 3 - Low
    2014-12-31 jwe Item GroupIncorrect Result WTF, Matlab?!?
    2013-06-22 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-ec27.
    Corresponding source code