Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- dedenter.rb: Fix squiggly heredoc line continuation handling #819

Commits on Sep 24, 2021

  1. Fix squiggly heredoc line continuation handling

    Firstly, this fixes an issue with non-interpolating squiggly heredocs,
    where line continuation characters should be ignored. Two things were
    broken:
    
    - The line continuation backslash would be removed, as well as the
      subsequent carriage return
    - The subsequent line would not be dedented.
    
    For example, the following source:
    
    <<~'END'
      foo \
      bar
    END
    
    Would be parsed as follows:
    
    (dstr
      (str "foo ")
      (str "  bar\n"))
    
    With the change, the result is:
    
    (dstr
      (str "foo \\\n")
      (str "bar\n"))
    
    This also fixes an issue with interpolating squiggly heredocs, where an
    escaped backslash followed by a newline would be interpreted as a line
    continuation.
    
    In that case, the following source:
    
    <<~END
      foo \\
      bar
    END
    
    Would (again) be parsed as follows:
    
    (dstr
      (str "foo ")
      (str "  bar\n"))
    
    With the change, the result is:
    
    (dstr
      (str "foo \\\n")
      (str "bar\n"))
    mvz committed Sep 24, 2021
    Copy the full SHA
    e1ef0ac View commit details
    Browse the repository at this point in the history