bugGNU Octave - Bugs: bug #44934, classdef parser prints extra...

 
 

bug #44934: classdef parser prints extra newline when failing to parse bad classdef file

Submitter:  Rik <rik5>
Submitted:  Mon 27 Apr 2015 05:19:46 AM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  1 - Later Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 17 Apr 2019 11:49:39 PM UTC, comment #5: 

Nice.  You are really cleaning up some small niggles.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 17 Apr 2019 11:21:28 PM UTC, comment #4: 

I pushed the following changeset to fix this problem.

http://hg.savannah.gnu.org/hgweb/octave/rev/44d1fe403c19

I don't know exactly what the original problem was, but in the current sources, the exclusive start state FQ_IDENT_START in the lexer wasn't recognizing newline characters so they were just being passed through to the output.  Very confusing behavior to track down since I kept trying to find where Octave was writing that to octave_stdout!

John W. Eaton <jwe>
Group administrator
Mon 27 Apr 2015 04:56:45 PM UTC, comment #3: 

The actual error when trying to instantiate an object from class DocSimpleDouble is


x = DocSimpleDouble

error: function, method, class, and package names may not be keywords
parse error near line 1 of file /home/rik/wip/Projects_Mine/octave-dev/DocSimpleDouble.m

  syntax error

>>>    methods


If I change the first line of DocSimpleDouble to


classdef DocSimpleDouble < methods


Then I get the nearly the same message, but there is no newline between the entering of the command and the line which begins with "error:".  This also works with tst_try.


octave:5> x = DocSimpleDouble
error: function, method, class, and package names may not be keywords
parse error near line 1 of file /home/rik/wip/Projects_Mine/octave-dev/DocSimpleDouble.m

  syntax error

>>> classdef DocSimpleDouble < methods


So maybe the problem is something in the classdef parser rather than try/catch.  Re-titling again.

Rik <rik5>
Group administrator
Mon 27 Apr 2015 04:48:59 PM UTC, comment #2: 

Further debugging shows that it is only a problem when the parser is trying to deal with an empty class name to inherit from.

Currently, the first line of DocSimpleDouble is


classdef DocSimpleDouble < \n


where I have explicitly shown the newline (it isn't shown in the editor).  With this configuration there is an extra newline printed from tst_try.m.

If I change the first line to


classdef DocSimpleDouble < abc


then there is no extra newline printed.



Rik <rik5>
Group administrator
Mon 27 Apr 2015 04:23:14 PM UTC, comment #1: 

I checked in a cset that stops Octave from searching for additional help text after an error is encountered (http://hg.savannah.gnu.org/hgweb/octave/rev/4ff975c58584).  This fixes the immediate problem reported in this bug, but I still get an extra newline (down to only 1) when running tst_try.m.  Re-titling the report to reflect that.

Rik <rik5>
Group administrator
Mon 27 Apr 2015 05:19:46 AM UTC, original submission:  

This is a bit involved, but there appears to be an error in the way get_help_text and parsing of classdef files with errors are done.

The set-up is to have DocSimpleDouble.m in the current directory (".").  Also in the current directory is the script tst_try.m.  Run tst_try and you will get two newlines ahead of the final retval for the function.  See below


>> tst_try


ans =  1
>>


When I run tst_try under 3.8.2 there are no extra newlines.

The newlines aren't such a big deal, but they seem to be indicative of a bigger problem.

If I run the failing line of tst_try in the dev version of Octave I get


>> get_help_text ('DocSimpleDouble')

error: function, method, class, and package names may not be keywords
parse error near line 1 of file /home/rik/wip/Projects_Mine/octave-dev/DocSimpleDouble.m

  syntax error

>>>    methods
                                 ^


error: function, method, class, and package names may not be keywords
parse error near line 1 of file ./DocSimpleDouble.m

  syntax error

>>>    methods
                                 ^

>>


What is odd is that there are two errors produced.  It is as if the error_status variable is getting set, but no one is checking it and get_help_text in corefcn/help.cc is continuing.  3.8.2 does the same thing, i.e., it produces two error messages.  But it doesn't produce two newlines in tst_try.m


Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #33815:  DocSimpleDouble.m added by rik5 (231B - text/x-objcsrc)
file #33816:  tst_try.m added by rik5 (142B - text/x-objcsrc)

 

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 (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-17 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2018-03-14 rik5 Priority5 - Normal 1 - Later
    2015-05-01 rik5 Severity3 - Normal 2 - Minor
    2015-04-27 rik5 Summarytry/catch prints extra newline when parsing bad classdef file classdef parser prints extra newline when failing to parse bad classdef file
    2015-04-27 rik5 Summarytry/catch prints extra newline try/catch prints extra newline when parsing bad classdef file
    2015-04-27 rik5 Summaryget_help_text issues two error messages when failing to parse classdef file try/catch prints extra newline
    2015-04-27 rik5 Attached File- Added DocSimpleDouble.m, #33815
        Attached File- Added tst_try.m, #33816

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code