Skip to content

Keep carriage returns and raw-string newlines in emitted string literals - #2380

Merged
Egorand merged 1 commit into
square:mainfrom
lenamonj:raw-string-line-terminators
Sep 11, 2026
Merged

Egorand merged 1 commit into
square:mainfrom
lenamonj:raw-string-line-terminators

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

A carriage return could not survive stringLiteralWithQuotes. The margin form writes the value into a """ literal, the lexer reads a bare CR as a line terminator, and trimMargin() rejoins the lines with \n, so a CRLF value came out LF-only. The raw-string form used for %P lost it the same way, and in a constant context wrote a bare newline that picked up indentation.

Values carrying a CR now take the escaped form, and a raw string splices both line terminators in as ${'\r'} and ${'\n'}, as the file already does for " and $. Values with newlines only are unchanged.

Verified with the added UtilTest.stringLiteral cases, red on main and green with the change, and ./gradlew build.

  • docs/changelog.md has been updated if applicable.
  • CLA signed.

@square-task-list-completed

square-task-list-completed Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

All tasks completed

@lenamonj
lenamonj force-pushed the raw-string-line-terminators branch from 5dd564e to 15fe64d Compare September 7, 2026 19:00

@Egorand Egorand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@Egorand
Egorand merged commit 17f828d into square:main Sep 11, 2026
7 checks passed
@lenamonj
lenamonj deleted the raw-string-line-terminators branch September 11, 2026 10:15
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