Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 6, 2025

Fixes #2992

This exposed a bug in swift-syntax, which I’m fixing:

Normalize line ending to \n in StringLiteralExprSyntax.representedLiteralValue

This matches the specification of multi-line string literal handling:

From https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#String-Literals:

Line breaks in a multiline string literal are normalized to use the line feed character. Even if your source file has a mix of carriage returns and line feeds, all of the line breaks in the string will be the same.

From https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170417/035923.html:

The quoted string should normalize newlines to \n in the value of the literal, regardless of whether the source file uses \n (Unix), \r\n (Windows), or \r (classic Mac) line endings. Likewise, when the compiler strips the initial and final newline from the literal value, it will strip one of any of the \n, \r\n, or \r line-ending sequences from both ends of the literal.

@ahoppen ahoppen force-pushed the enable-windows branch 3 times, most recently from 5b12853 to 099f141 Compare March 7, 2025 02:22
@ahoppen ahoppen marked this pull request as ready for review March 7, 2025 02:23
@ahoppen ahoppen requested a review from bnbarham as a code owner March 7, 2025 02:23
…LiteralValue`

This matches the specification of multi-line string literal handling:

From https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#String-Literals:
> Line breaks in a multiline string literal are normalized to use the line feed character. Even if your source file has a mix of carriage returns and line feeds, all of the line breaks in the string will be the same.

From https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170417/035923.html:

> The quoted string should normalize newlines to \n in the value of the literal, regardless of whether the source file uses \n (Unix), \r\n (Windows), or \r (classic Mac) line endings. Likewise, when the compiler strips the initial and final newline from the literal value, it will strip one of any of the \n, \r\n, or \r line-ending sequences from both ends of the literal.
@ahoppen
Copy link
Member Author

ahoppen commented Mar 7, 2025

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge March 7, 2025 07:28
@ahoppen ahoppen merged commit f2a32a7 into swiftlang:main Mar 7, 2025
22 checks passed
@ahoppen ahoppen deleted the enable-windows branch August 4, 2025 10:49
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.

Enable Windows CI checks in GitHub Actions

2 participants