Skip to content

Conversation

@Earlopain
Copy link
Collaborator

@Earlopain Earlopain commented Dec 24, 2024

Builds on top of #3341, will fix rubocop/rubocop#12878

This does a few things:

  • After a line continuation in a heredoc, emit only a single token
  • Dedent ` heredocs
  • Properly handle escapes in single and doublequoted heredocs

Some of the heredoc escaping logic should be applied to strings as well,
but I'll leave that for a different PR.

Also, if the heredoc consists only of literal string content, this new escaping branch is not yet taken. It only works if interpolation is used.

@Earlopain Earlopain force-pushed the parser-translator-escaping-heredoc-strings branch 3 times, most recently from b751c75 to 79ea4e6 Compare December 24, 2024 09:31
In parser, the string content is dedented. This implements these rules
as far as I was able to understand them. It's all a bit confusing with
spaces/tabs, always learning more funny things about them.

I refered to the prism implementation, parser seems to adhere to it very closely.
This does a few things:
* After a line continuation in a heredoc, emit only a single token
* Dedent ` heredocs
* Properly handle escapes in single and doublequoted heredocs

Some of the heredoc escaping logic should be applied to strings as well,
but I'll leave that for a different PR.
Copy link
Collaborator

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I think we will need to share this escaping logic with the parser translation as well, but that can be done later.

@kddnewton kddnewton merged commit cd3ced2 into ruby:main Jan 3, 2025
56 checks passed
@Earlopain Earlopain deleted the parser-translator-escaping-heredoc-strings branch January 5, 2025 19:52
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 Lint/ImplicitStringConcatenation with prism

2 participants