patchGNU Octave - Patches: patch #9023, Tell user about misaligned if/end...

 
 

patch #9023: Tell user about misaligned if/end pairs when an end-related error occurs

Submitted by:  Lachlan Andrew <lachlan>
Submitted on:  Fri 10 Jun 2016 09:18:19 AM UTC  
 
Category:  Core : new feature Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  Lachlan Andrew <lachlan> Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 13 Jun 2016 09:52:43 AM UTC, comment #1:

Note: The patch accidentally has tabs in it. I'll remove them in the next version, but will wait for feedback first.

Lachlan Andrew <lachlan>In charge of this item.
Fri 10 Jun 2016 09:18:19 AM UTC, original submission:

This patch gives users a hint about where a missing or spurious "end" (or "endif" or "endfor" etc.) might be.

It uses the heuristic that the "end" should start at the same level of indentation as the "if" or whatever, or perhaps be on the same line as the "if". It records if/end pairs for which that doesn't occur. If an error occurs that is likely to be due to mismatched ends, it augments the error message with a note telling the user the innermost pair that start in different columns.

This is most useful for those of us who have to write Matlab-compatible code, since the dedicated forms of endXYZ provide some help with this, but in deeply nested "if" or "for" statements, it still reduces the ambiguity.

If users have a coding style in which the "end" is supposed to have a different indent, this will not create excess diagnostics, since it only prints anything when an error occurs. Also, the output is only of the form

which doesn't say that that is the cause of the error.

Lachlan Andrew <lachlan>In charge of this item.

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-07 lachlan CategoryNone => Core : new feature
    2016-06-10 lachlan Attached File- => Added patch_warn_misaligned_ends.cset, #37445

    Back to the top


    Powered by Savane 3.3