RFC 0021: Percent String Array Literal with Interpolation - #21
Merged
straight-shoota merged 14 commits intoJul 15, 2026
Merged
Conversation
This was referenced Feb 25, 2026
ysbaddaden
reviewed
Feb 26, 2026
Co-authored-by: Julien Portalier <julien@portalier.com>
ysbaddaden
approved these changes
Feb 26, 2026
straight-shoota
marked this pull request as ready for review
February 28, 2026 20:40
HertzDevil
reviewed
Mar 3, 2026
| %W[foo #{"bar"}baz#{"bab"} qux] # => ["foo", "barbazbab", "qux"] | ||
| %W[foo _#{"bar"}_ baz] # => ["foo", "_bar_", "baz"] | ||
| %W[foo #{"bar baz"} qux] # => ["foo", "bar baz", "qux"] | ||
| ``` |
There was a problem hiding this comment.
IMO this should show the immediate transformations performed by the compiler, more specifically the parser, rather than the final results of the expressions. If I have to guess, this would mean:
["foo", "#{1 + 1}", "baz"] of ::String
["foo", "#{"bar"}baz#{"bab"}", "qux"] of ::Stringand also splat elements would be retained verbatim, without introducing another StringInterpolation node:
["foo", *%w[bar baz], "qux"] of ::String
Member
Author
There was a problem hiding this comment.
Good point. The reference-level explanation is actually just an extended guide-level and does not explain the technical details. I'll expand on that 👍
The markdownlint config has been adapted from the established https://github.com/crystal-lang/crystal-website/blob/27838d03a6be4d375d1c123a246446e97050add5/.markdownlint.yaml
ysbaddaden
reviewed
Mar 3, 2026
Co-authored-by: Julien Portalier <julien@portalier.com>
straight-shoota
added a commit
to crystal-lang/crystal
that referenced
this pull request
Mar 4, 2026
This is a bit of code cleanup, avoiding unnecessary intermediaries and removing duplication. It's in preparation for implementing `%W` string array literals (crystal-lang/rfcs#21).
ysbaddaden
approved these changes
Mar 9, 2026
|
This pull request has been mentioned on Crystal Forum. There might be relevant details there: https://forum.crystal-lang.org/t/rfc-0021-percent-string-array-literal-with-interpolation/8772/1 |
This was referenced Mar 10, 2026
straight-shoota
added a commit
to crystal-lang/crystal
that referenced
this pull request
Mar 17, 2026
This is a plain refactoring to extract behaviour into helper methods. It helps structure the code and prepares for reusing these helpers to implement interpolation for string array literals ([RFC 0021](crystal-lang/rfcs#21)).
This was referenced Mar 17, 2026
straight-shoota
added a commit
to crystal-lang/crystal
that referenced
this pull request
Mar 19, 2026
…16747) Continuation of #16720, but extracted into a separate commit for a cleaner diff because of overlap. This is a plain refactoring to extract behaviour into helper methods. It helps structure the code and prepares for reusing these helpers to implement interpolation for string array literals ([RFC 0021](crystal-lang/rfcs#21)).
straight-shoota
added a commit
to crystal-lang/crystal
that referenced
this pull request
May 4, 2026
Previously, string array literal parsing used a custom implementation, combined with a custom lexer mode (`next_string_array_token`). This patch changes that to reuse the same parser and lexer features as other string literals. This standardization removes an extra concept and thus reduces code surface area. In return, we're adding some conditionals for this specific literal type into the standard implementations. This increases complexity a little bit, but it's still fairly easy to reason about and a common pattern in the parser. Combining the parsing of all string-related literals clearly shows their differences (in the form of such conditionals) and ensures consistent behaviour. In particular, this change establishes standard behaviour for escape characters, and thus fixes #12277 However, it's unclear whether we accept this behaviour change (see #12277 (comment)). If not, we need to implement a non-standard escape algorithm to ensure backwards-compatibility. The main motivation for this refactor is that it opens the path for implementing string literals with interpolation ([RFC 0021](crystal-lang/rfcs#21)). Co-authored-by: Julien Portalier <julien@portalier.com>
straight-shoota
added a commit
to crystal-lang/crystal
that referenced
this pull request
Jun 3, 2026
This implements [RFC 21]. [RFC 21]: crystal-lang/rfcs#21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preview: https://github.com/crystal-lang/rfcs/blob/rfc/percent-array-literal-interpolation/text/0021-percent-array-literal-interpolation.md