Actions
Bug #22561
openparse.y rejects empty heredocs terminated by `\r\n` (`<<""\r\n\r\n`)
Bug #22561:
parse.y rejects empty heredocs terminated by `\r\n` (`<<""\r\n\r\n`)
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +PRISM [arm64-darwin27]
Description
CRuby parse.y rejects empty-delimiter heredocs (<<'', <<"", <<-'', <<~'') whenever the closing blank terminator line uses \r\n (CRLF), raising SyntaxError: can't find string "" anywhere before EOF—even though parse.y accepts non-empty heredocs with \r\n (<<'A'\r\nA\r\n) as well as empty heredocs with \n (<<''\n\n). Prism accepts empty heredocs with \r\n cleanly.
Tested on CRuby 4.0.9 (--parser=parse.y vs --parser=prism):
# Empty heredoc with CRLF line endings:
ruby --parser=prism -e "$(printf 'p <<""\r\n\r\n')" # exits 0, prints ""
ruby --parser=parse.y -e "$(printf 'p <<""\r\n\r\n')" # exits 1: can't find string "" anywhere before EOF
# Mixed LF opening line + CRLF closing line, and indented variants:
for open in "<<''" '<<""' "<<-''" "<<~''"; do
printf "p %s\r\n\r\n" "$open" | ruby --parser=prism
printf "p %s\r\n\r\n" "$open" | ruby --parser=parse.y
done
# Non-empty heredoc with CRLF works in both:
ruby --parser=parse.y -e "$(printf "p <<'A'\r\nA\r\n")" # exits 0, prints ""No data to display
Actions