bugGNU Octave - Bugs: bug #57121, lexer counts lines incorrectly for...

 
 

bug #57121: lexer counts lines incorrectly for block comments that immediately follow line comments

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Sun 27 Oct 2019 03:19:18 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  jwe
Originator Name:  Philip Nienhuis 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

Mon 28 Oct 2019 11:42:10 PM UTC, comment #9: 

I just cheked and the patch works for both line 459 and line 479 in pkg.m.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 28 Oct 2019 08:22:48 PM UTC, comment #8: 

FTR, in the original pkg.m the same happens for L.479 ("cellfun ..."), the pointer ends up one line further down.

I haven't tried the fix in comment #7 yet.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 28 Oct 2019 05:09:44 PM UTC, comment #7: 

I pushed the following change instead of the one-line fix because it seems better to use more but simpler rules.

http://hg.savannah.gnu.org/hgweb/octave/rev/5aad387784aa

John W. Eaton <jwe>
Group administrator
Mon 28 Oct 2019 04:30:54 AM UTC, comment #6: 

Thanks for the report.  I think the problem is with the block comment immediately following a line comment.  The line that starts the block comment is being counted twice, once as a line comment and again as the start of a block.

I'm attaching a simple one-line fix for now but I have an idea for a better solution that will simplify this part of the lexer.  I'll try to look at it tomorrow.


(file #47754)

John W. Eaton <jwe>
Group administrator
Sun 27 Oct 2019 11:56:15 PM UTC, comment #5: 

Also confirmed.  The simplest test is


dbstop pkg 459
ans = 460


The code from pkg.m is


        else
459 ->    looks_like_pkg_name = regexp (file, '^[\w-]+$');
          if (looks_like_pkg_name)
            error (["pkg: file not found: %s.\n" ...
                    "This looks like an Octave Forge package name." ...
                    "  Did you mean:\n" ...
                    "       pkg install -forge %s"], ...
                   file, file);
          else
            error ("pkg: file not found: %s", file);
          endif
        endif


I added a new line 460 with


disp ('Hello World');


but this has no effect.

I also found that setting a breakpoint at line 458 (else) or line 459 (regexp) both result in line 460 as the selected line.

Finally, reversing the lines so it reads


        else
459 ->    disp ('Hello World');
looks_like_pkg_name = regexp (file, '^[\w-]+$');


also has the same issue.

It would seem that there is something wrong with the line number counting of the interpreter immediately following an else keyword.


Rik <rik5>
Group administrator
Sun 27 Oct 2019 09:03:52 PM UTC, comment #4: 

Confirmed, trying to set a breakpoint at 459 results in a bp in 460.

But I think, it is not just the pointer in the gui, which points to the wrong line, because


>> dbstop "pkg" 459
ans = 460
>> dbstatus
breakpoint in pkg at line 460



Torsten Lilge <ttl>
Group Member
Sun 27 Oct 2019 08:42:32 PM UTC, comment #3: 

@Torsten: I made a typo, sorry.
Try to put the breakpoint at L.459 (line after the "else"). Setting it at L.460 "if (looks_like_pkg_name)" works fine here as well.

I see it on Windows and on Linux, only in the GUI (didn't try the CLI).
AFAICS it's just that the pointer is off by one line.
I also saw it in other (private) functions of pkg.m but the pkg.m case is very reliably reproducible here.

FWIW, I saw more behavior that is non-conformant: sometimes when I adapt code and save the function to disk, followed by "clear -f", the changes aren't picked up and I have to restart Octave. I'm used to private functions needing "clear -f" before changes are picked up; but that even then changes are ignored was new.




Philip Nienhuis <philipnienhuis>
Group Member
Sun 27 Oct 2019 05:53:26 PM UTC, comment #2: 

@Philip: You marked the Operating System as "Any".  Were you able to reproduce this on Linux, or is this connected solely to MS Windows?

Rik <rik5>
Group administrator
Sun 27 Oct 2019 04:50:29 PM UTC, comment #1: 

I can't reporduce this. When setting the breakpoint at line 460, either in the editor or using dbstop, it is set to line 460 , i.e., if (looks_like_pkg_name).

Is the offset only showing up in the gui editor or is the breakpoint really set the wrong line? What happens if you use dbstop instead of clicking into the editor margin?

Torsten Lilge <ttl>
Group Member
Sun 27 Oct 2019 03:19:18 PM UTC, original submission:  

(I hope this is not a duplicate, I searched but couldn't find similar reports)

Steps to reproduce:

Edit pkg.m

In the editor, add breakpoints at the following places:
L.377 (switch stmt) -> OK
L.436 (error ....) -> still OK
L.460 -> off by one line

Also when stepping through the code the instruction pointer gets off by one line more or less after L.436 (I guess as I didn't actually get there but at L.377 it's OK, when jumping through the switch to beyond L.460 it's offset).

Philip Nienhuis <philipnienhuis>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #47754:  lexer-diffs.txt added by jwe (408B - 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 (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by philipnienhuis (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-10-28 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-10-28 jwe StatusIn Progress Ready For Test
    2019-10-28 jwe Attached File- Added lexer-diffs.txt, #47754
        StatusConfirmed In Progress
        Assigned toNone jwe
        Summary[GUI] debug pointer position off by one line lexer counts lines incorrectly for block comments that immediately follow line comments
    2019-10-27 rik5 StatusNeed Info Confirmed
    2019-10-27 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code