Skip to content

Conversation

@Earlopain
Copy link
Collaborator

@Earlopain Earlopain commented Jan 7, 2025

Fixes rubocop/rubocop#12870

For example:

"a
#{}
c
"

The parser gem produces

s(:dstr,
  s(:str, "a\n"),
  s(:begin),
  s(:str, "\n"),
  s(:str, "c\n"))

While the translator wraps the last two string nodes in a dstr. There was already logic that kinda was supposed to handle this but it was too specific, applying only when the interpolation contains a single string node.

Much of this logic should be shared between interpolated symbols and regexps. It's also incorrect when the node contains a literal \\n (same as for plain string nodes at the moment).

After #3373 is merged, the added method for creating string nodes can be used to make it more correct in all of these cases.

Much of this logic should be shared between interpolated symbols and regexps.
It's also incorrect when the node contains a literal `\\n` (same as for plain string nodes at the moment)
@tenderlove tenderlove merged commit 0df78f7 into ruby:main Jan 7, 2025
56 checks passed
@Earlopain Earlopain deleted the parser-translator-multiline-interpolated-string branch January 7, 2025 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive for Layout/LineEndStringConcatenationIndentation with Prism

2 participants