Skip to content

Conversation

@Earlopain
Copy link
Collaborator

See https://bugs.ruby-lang.org/issues/21756. Ripper fails to parse this but prism actually also doesn't handle it correctly.

When heredocs are used, even in lowercase percent arays there can be
multiple STRING_CONTENT tokens. We need to concat them.

Luckily we don't need to handle as many cases as in uppercase arrays where interpolation is allowed. Mostly inspired by how uppercase arrays are handled.

%q strings seem to work ok already.

Second commit is a pretty small fix I noticed while I was poking around. Probably a copy-paste error.

See https://bugs.ruby-lang.org/issues/21756. Ripper fails to parse this,
but prism actually also doesn't handle it correctly.

When heredocs are used, even in lowercase percent arays there can be
multiple `STRING_CONTENT` tokens. We need to concat them.

Luckily we don't need to handle as many cases as in uppercase arrays where interpolation is allowed.
Not so sure how to trigger it but this is definitly more correct.
@Earlopain Earlopain force-pushed the percent-array-heredoc-continuation branch 2 times, most recently from 3497ea8 to 1bc8ec5 Compare December 3, 2025 08:20
@Earlopain Earlopain marked this pull request as ready for review December 3, 2025 08:32
pm_array_node_t *array = pm_array_node_create(parser, &opening);

// skip all leading whitespaces
accept1(parser, PM_TOKEN_WORDS_SEP);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was not needed, the loop already consumsed the separator. Removed because it was already not present in %i handling

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.

Looks right to me!

@kddnewton kddnewton merged commit 81051c1 into ruby:main Dec 3, 2025
64 checks passed
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.

2 participants