whitequark / whitequark/parser

Escaped newlines in single-quoted heredocs

Open
#950 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Yacc
Stars
1.6k
Forks
205
PR merge metrics
No merged PRs in 30d

Description

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"))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the discrepancy with test/tmp/test.rb, comparing ruby --dump=insns with bin/ruby-parse for the single-quoted heredoc shown. Trace how each output represents the escaped newline, then make the parser agree with Ruby and verify both command outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.