whitequark / parser

A Ruby parser.
Other
1.57k stars 197 forks source link

Escaped newlines in single-quoted heredocs #950

Open kddnewton opened 10 months ago

kddnewton commented 10 months ago

In the following snippet:

<<~'FOO'
  baz\\
  qux
FOO

For Ruby you will get:

$ ruby --dump=insns test/tmp/test.rb
== disasm: #<ISeq:<main>@test/tmp/test.rb:1 (1,0)-(1,8)> (catch: false)
0000 putstring                              "baz\\\\\nqux\n"          (   1)[Li]
0002 leave

but for parser you get:

$ bin/ruby-parse test/tmp/test.rb
(dstr
  (str "baz\\\n")
  (str "qux\n"))