Project

General

Profile

Actions

Bug #11989

closed

Dedenting interpolating heredoc can interpret escapes incorrectly

Added by whitequark (whitequark *) over 8 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[ruby-core:72855]

Description

It is clear that the dedenting <<~HEREDOC feature was intended to only consider actual whitespace in the source file as indentation, not any escaped whitespace. E.g.:

p <<~"E"
  \ x
   y
E

It prints " x\n y\n". So "\ " does not count as whitespace. There is even an MRI test for this.

However, this case is handled differently:

p <<~"E"
  x\n   y
E

It prints "x\n y\n". So "\n" is counted as whitespace, like an actual newline would be. I think it should print "x\n y\n".


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect valueClosedActions

Updated by whitequark (whitequark *) over 8 years ago

  • Description updated (diff)
Actions #2

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

  • Status changed from Open to Closed

Applied in changeset r53573.


parse.y: escaped newline in dedenting heredoc

  • parse.y (parser_here_document): an escaped newline is not an
    actual newline, and the rest part should not be dedented.
    [ruby-core:72855] [Bug #11989]
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Description updated (diff)
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED
Actions #4

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Related to Bug #14584: Squigly heredoc with interpolation that has a string literal withe spaces gets incorrect value added

Updated by usa (Usaku NAKAMURA) about 6 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

ruby_2_3 r62826 merged revision(s) 53573.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0