bugGNU Octave - Bugs: bug #55812, Interpreter gives incorrect line...

 
 

bug #55812: Interpreter gives incorrect line number for class name / file name mismatch

Submitter:  Rik <rik5>
Submitted:  Sat 02 Mar 2019 06:22:12 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 17 Apr 2019 05:16:23 PM UTC, comment #5: 

Beautiful.  Very clear now where the error is.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Wed 17 Apr 2019 04:05:02 PM UTC, comment #4: 
John W. Eaton <jwe>
Group administrator
Mon 25 Mar 2019 09:23:07 PM UTC, comment #3: 

This looks harder to fix than I had hoped.  Unfortunately, the parser has already advanced to the endclassdef statement when the function in oct-parse.yy that emits the error is invoked.

Rik <rik5>
Group administrator
Sun 03 Mar 2019 03:22:16 PM UTC, comment #2: 

classdef needs to be the first true code in a file, and the keyword can only occur once in the file.

Rik <rik5>
Group administrator
Sun 03 Mar 2019 08:47:28 AM UTC, comment #1: 

With a classdef, is it like a function in that the first line of script code must match the file name?  Or is it that the definition must exist somewhere within the file?  If the former, then yeah Line #1 makes more sense.  If the latter, then maybe Line #[last line] makes more sense--but if that were the case then the error shouldn't be "the class name must match the filename".

Dan Sebald <sebald>
Sat 02 Mar 2019 06:22:12 PM UTC, original submission:  

When parsing a classdef file the name of the class must match the name of the file exactly.  If it does not, Octave emits an error about the mismatch, but incorrectly points to the line in the file corresponding to "endclassdef" rather than the true source of the error which is the initial "classdef" statement.

I found this accidentally with the following code which I placed in the lowercase filename "mydumbclass.m"


classdef MyDumbClass

  properties
    data
  endproperties

  methods
    function this = MyDumbClass (data)
      this.data = data;
    endfunction

    function out = sizeof (this)
      out = sizeof (this.data);
    endfunction
  endmethods

endclassdef


When trying to create an instance of the class I received the following error


octave:1> x = mydumbclass
parse error near line 17 of file /home/rik/wip/Projects_Mine/octave-dev/mydumbclass.m

  invalid classdef definition, the class name must match the filename

>>> endclassdef


It would be better if it cited line 1 and gave this reference


>>> classdef MyDumbClass



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

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-17 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-04-17 jwe StatusConfirmed Ready For Test

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code