whitequark / parser

A Ruby parser.
Other
1.59k stars 199 forks source link

Escaped newlines in single-quoted heredocs #950

Open kddnewton opened 1 year ago

kddnewton commented 1 year 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"))