cylc-flow icon indicating copy to clipboard operation
cylc-flow copied to clipboard

line continuation in a comment

Open hjoliver opened this issue 5 years ago • 4 comments

Describe the bug

Commenting out a line that ends in a line-continuation back-slash causes the subsequent line to become part of the comment.

Release version(s) and/or repository branch(es) affected? Current 7.8.x and master

Steps to reproduce the bug

[scheduling]
   [[graph]]
      R1 = """
         # foo => \
            baz => \
            qux
              """

That is equivalent (wrongly) to this:

[scheduling]
   [[graph]]
      R1 = """
         # foo => baz => qux
              """

Expected behavior

We discourage use of line continuation characters in the graph because they are no longer needed. Using natural continuation (implied by trailing =>):

[scheduling]
   [[graph]]
      R1 = """
         # foo => 
            baz => 
            qux
              """

that is equivalent (correctly) to:

[scheduling]
   [[graph]]
      R1 = """
         # foo => 
            baz => qux
              """

Additional context

This comment-continuation effect will apply anywhere in the file, but it is most likely to be encountered in graph strings (because users quite commonly comment bits of a graph out, and may not be aware that trailing \ is not needed for continuation in graph strings).

Unfortunately line continuation markers are stripped first thing during file parsing, where the context is unknown. We could ignore continuation markers if preceded anywhere on the line by a comment character - but need to be careful about # inside a string, if not inside a graph string? (which might be fiendishly difficult? might require abandoning the simple handling of line continuation first up during file parsing?).

A user at NIWA hit this problem last week, but it is the first time I've ever seen it, so could be classified rare bug, no desperate need to fix it quickly if difficult to do.

Pull requests welcome! This is an Open Source project - please consider contributing a bug fix yourself (please read CONTRIBUTING.md before starting any work though).

hjoliver avatar Sep 15 '19 20:09 hjoliver

Potentially slightly dangerous to change the behaviour now? As a minimum we should document the behaviour.

dpmatthews avatar Feb 20 '20 12:02 dpmatthews

Potentially slightly dangerous to change the behaviour now?

Tough call ... I don't think anyone would be relying on the current behaviour would they? At least not deliberately.

As a minimum we should document the behaviour.

Yes, I'll reference this page on cylc-doc for Cylc 8. We should also document this for 7.8.5 though.

hjoliver avatar Feb 20 '20 20:02 hjoliver

Case 2

(From @dpmatthews on Riot chat)

       #c => \_
           d => e

I've added a space after the continuation marker and it gets ignored in this case. However, for an uncommented line this would result in an error so this behaviour is not consistent.

hjoliver avatar Feb 20 '20 20:02 hjoliver

Stop joining lines within multi-line strings. Reimplement within graph parser.

hjoliver avatar Aug 04 '21 10:08 hjoliver