Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parser translator ast for heredoc with written newlines #3347

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Earlopain
Copy link
Contributor

Heredocs don't don't start a new string node when encountering "\\n".

Builds on top of #3341, but only because the tokens would otherwise not line up. It's otherwise totally standalone. Will actually fix rubocop/rubocop#12878

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.
Heredocs that contain "\\n" don't start a new string node.
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
1 participant