Skip to content

Enable Windows tests in GitHub Actions #2993

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

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
# https://github.com/swiftlang/swift-syntax/issues/2992
enable_windows_checks: false
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftParser/Lexer/Cursor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ extension Lexer.Cursor {
// MARK: Lexing a character in a string literal

extension Lexer.Cursor {
enum CharacterLex {
enum CharacterLex: Equatable {
/// A normal character as it occurs in the source file
case success(Unicode.Scalar)

Expand Down
16 changes: 14 additions & 2 deletions Sources/SwiftParser/StringLiteralRepresentedLiteralValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ extension StringSegmentSyntax {
precondition(!hasError, "appendUnescapedLiteralValue relies on properly parsed literals")

let rawText = content.rawText
if !rawText.contains("\\") {
// Fast path. No escape sequence.
if !rawText.contains(where: { $0 == "\\" || $0 == "\r" }) {
// Fast path. No escape sequence that need to be interpreted or line endings that need to be normalized to \n.
output.append(String(syntaxText: rawText))
return
}
Expand All @@ -105,6 +105,18 @@ extension StringSegmentSyntax {
)

switch lex {
case .success(Unicode.Scalar("\r")):
// Line endings in multi-line string literals are normalized to line feeds even if the source file has a
// different encoding for new lines.
output.append("\n")
if cursor.peek() == "\n" {
// If we have \r\n, eat the \n as well and leave
let consumed = cursor.lexCharacterInStringLiteral(
stringLiteralKind: stringLiteralKind,
delimiterLength: delimiterLength
)
assert(consumed == .success(Unicode.Scalar("\n")))
}
case .success(let scalar),
.validatedEscapeSequence(let scalar):
output.append(Character(scalar))
Expand Down