Project

General

Profile

Actions

Bug #21756

open

Ripper fails to parse pathological heredoc

Bug #21756: Ripper fails to parse pathological heredoc

Added by Earlopain (Earlopain _) about 9 hours ago. Updated about 1 hour ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-11-28T10:49:46Z master dcb9e17f46) +PRISM [x86_64-linux]
[ruby-core:123971]

Description

# test.rb
pp <<-A, %w[j\
i
A
j]
$ RBENV_VERSION=ruby-dev ruby -rripper -ve "Ripper.lex(File.read('test.rb'), raise_errors: true)"
ruby 4.0.0dev (2025-11-28T10:49:46Z master dcb9e17f46) +PRISM [x86_64-linux]
/home/user/.rbenv/versions/ruby-dev/lib/ruby/4.0.0+0/ripper/lexer.rb:180:in 'Ripper::Lexer#parse': syntax error, unexpected literal content, expecting ' ' (SyntaxError)
        from /home/user/.rbenv/versions/ruby-dev/lib/ruby/4.0.0+0/ripper/lexer.rb:155:in 'Ripper::Lexer#lex'
        from /home/user/.rbenv/versions/ruby-dev/lib/ruby/4.0.0+0/ripper/lexer.rb:52:in 'Ripper.lex'
        from -e:1:in '<main>'

Both prism and parse.y are able to interpret this code:

$ RBENV_VERSION=ruby-dev ruby test.rb
"i\n"
["j\n", "j"]
$ RBENV_VERSION=ruby-dev ruby --parser=parse.y test.rb
"i\n"
["j\n" + "j"]
Actions

Also available in: PDF Atom