ruby / prism

Prism Ruby parser
https://ruby.github.io/prism/
MIT License
792 stars 134 forks source link

`Prism::Translation::RubyParser` - Separate lines inside squiggly heredocs not combined #2828

Closed presidentbeef closed 2 months ago

presidentbeef commented 2 months ago

..when there is interpolation:

> RubyParser.new.parse("<<~HERE\n\ \#{1}\n b\n c\nHERE")
 => s(:dstr, "", s(:evstr, s(:lit, 1)), s(:str, "\nb\nc\n"))
> Prism::Translation::RubyParser.parse("<<~HERE\n\ \#{1}\n b\n c\nHERE")
 => s(:dstr, "", s(:evstr, s(:lit, 1)), s(:str, "\n"), s(:str, "b\n"), s(:str, "c\n"))

Note without interpolation:

> Prism::Translation::RubyParser.parse("<<~HERE\n\ a\n b\n c\nHERE")
 => s(:str, "a\nb\nc\n")

And compare to regular heredoc:

> Prism::Translation::RubyParser.parse("<<-HERE\n\ \#{1}\n b\n c\nHERE")
 => s(:dstr, " ", s(:evstr, s(:lit, 1)), s(:str, "\n b\n c\n"))