bugGNU Octave - Bugs: bug #59150, Parse error when concatenating...

 
 

bug #59150: Parse error when concatenating strings from multiple lines

Submitter:  Guillaume <gyom>
Submitted:  Sun 20 Sep 2020 09:56:23 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 22 Sep 2020 06:55:43 PM UTC, comment #8: 

Verified.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Tue 22 Sep 2020 06:23:06 PM UTC, comment #7: 

I pushed the following changeset on stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/20b4bd415083

John W. Eaton <jwe>
Group administrator
Tue 22 Sep 2020 10:08:41 AM UTC, comment #6: 

Thanks. I tried the patch and it seems to work for me too with no unexpected side effects.

Guillaume <gyom>
Tue 22 Sep 2020 01:07:19 AM UTC, comment #5: 

I'm attaching a patch to try.  It's conservative in that it only changes the behavior inside matrix lists.  It seems to work for me.


(file #49835)

John W. Eaton <jwe>
Group administrator
Mon 21 Sep 2020 11:54:38 PM UTC, comment #4: 

I think Matlab is also flummoxed, but that Octave should probably treat continuation as equivalent to " ...".

In Matlab, matrix concatenation with character vectors acts as though there was a space.  The motivating example produces


T = [...
'A'...
'B']
T = 'AB'


If the line continuation replaced the newline and added a space the new code would be


T = [ 'A' 'B']


which on Octave would also produce the row string vector 'AB'.

To test my understanding, I tried using a comma as the joining character and it works both ways.


T = [...
'A'...
,'B']
T = 'AB'


OR


T = [...
'A',...
'B']


The second case illustrates that it isn't a continuation operator followed immediately by a character that is the problem.

Also, here's another example that doesn't use strings but that doesn't concatenate properly in Octave.


T = [...
{1}...
{2}]


Rik <rik5>
Group administrator
Mon 21 Sep 2020 09:20:30 PM UTC, comment #3: 

This example suggests the later, no? I don't manage to build a counter-example where it is not equivalent to being replaced by a space character.

Guillaume <gyom>
Mon 21 Sep 2020 06:46:10 PM UTC, comment #2: 

Is the continuation marker just supposed to suppress the newline or is it also supposed to behave as a space character?

John W. Eaton <jwe>
Group administrator
Mon 21 Sep 2020 04:07:20 PM UTC, comment #1: 

Re-titling to "Parse error" rather than "Par error".

Confirmed.  Interestingly, this goes way, way back.  I found the problem behavior present in version 3.2.4.

Rik <rik5>
Group administrator
Sun 20 Sep 2020 09:56:23 AM UTC, original submission:  

There is a parse error with the following:


T = [...
'A'...
'B'];



error: parse error:
  syntax error
>>> 'B'];
     ^


and it works fine again after adding a space at the beginning of the third line:


T = [...
'A'...
 'B'];


Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49835:  continuation-patch.txt added by jwe (860B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-22 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2020-09-22 jwe StatusConfirmed Ready For Test
    2020-09-22 jwe Attached File- Added continuation-patch.txt, #49835
    2020-09-21 rik5 StatusNone Confirmed
        SummaryPar error when concatenating strings from multiple lines Parse error when concatenating strings from multiple lines

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code