Skip to content

Commit f2a32a7

Browse files
authored
Merge pull request #2993 from ahoppen/enable-windows
Enable Windows tests in GitHub Actions
2 parents 52c9df9 + 33a5ad4 commit f2a32a7

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Diff for: .github/workflows/pull_request.yml

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ jobs:
88
tests:
99
name: Test
1010
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
11-
with:
12-
# https://github.com/swiftlang/swift-syntax/issues/2992
13-
enable_windows_checks: false
1411
soundness:
1512
name: Soundness
1613
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Diff for: Sources/SwiftParser/Lexer/Cursor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ extension Lexer.Cursor {
15941594
// MARK: Lexing a character in a string literal
15951595

15961596
extension Lexer.Cursor {
1597-
enum CharacterLex {
1597+
enum CharacterLex: Equatable {
15981598
/// A normal character as it occurs in the source file
15991599
case success(Unicode.Scalar)
16001600

Diff for: Sources/SwiftParser/StringLiteralRepresentedLiteralValue.swift

+14-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ extension StringSegmentSyntax {
8383
precondition(!hasError, "appendUnescapedLiteralValue relies on properly parsed literals")
8484

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

107107
switch lex {
108+
case .success(Unicode.Scalar("\r")):
109+
// Line endings in multi-line string literals are normalized to line feeds even if the source file has a
110+
// different encoding for new lines.
111+
output.append("\n")
112+
if cursor.peek() == "\n" {
113+
// If we have \r\n, eat the \n as well and leave
114+
let consumed = cursor.lexCharacterInStringLiteral(
115+
stringLiteralKind: stringLiteralKind,
116+
delimiterLength: delimiterLength
117+
)
118+
assert(consumed == .success(Unicode.Scalar("\n")))
119+
}
108120
case .success(let scalar),
109121
.validatedEscapeSequence(let scalar):
110122
output.append(Character(scalar))

0 commit comments

Comments
 (0)