Issue #11989 has been updated by whitequark *.

Description updated

----------------------------------------
Bug #11989: Dedenting interpolating heredoc can interpret escapes incorrectly
https://bugs.ruby-lang.org/issues/11989#change-56091

* Author: whitequark *
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
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"`.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>