PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: swiftlang/swift-syntax (swift)

Issue:
Too much skipping after invalid token in `for` element name
### Issue Kind

Bad Diagnostic Produced

### Source Code

```swift
for var elem? in arr { }
```

### Description

This results diagnostics:
```
test.swift:1:13: error: expected 'in' and expression in 'for' statement
1 │ for var elem? in arr { }
  │             ├─ error: expected 'in' and expression in 'for' statement
  │             ╰─ error: unexpected code '? in arr' in 'for' statement
2 │ 
```
And in the parsed syntax tree `? in arr ` part is parsed as `CodeBlockItemSyntax.unexpectedBeforeLeftBrace`

Pull request:
Fixed #2406

Patch:
diff --git a/Sources/SwiftParser/TokenPrecedence.swift b/Sources/SwiftParser/TokenPrecedence.swift
index c2d0d708515..fdf8eda3ad7 100644
--- a/Sources/SwiftParser/TokenPrecedence.swift
+++ b/Sources/SwiftParser/TokenPrecedence.swift
@@ -203,9 +203,7 @@ enum TokenPrecedence: Comparable {
       // Consider 'any' a prefix operator to a type and a type is expression-like.
       .Any,
       // 'where' can only occur in the signature of declarations. Consider the signature expression-like.
-      .where,
-      // 'in' occurs in closure input/output definitions and for loops. Consider both constructs expression-like.
-      .in:
+      .where:
       self = .exprKeyword
 
     case  // Control-flow constructs
@@ -213,7 +211,9 @@ enum TokenPrecedence: Comparable {
       // Secondary parts of control-flow constructs
       .case, .catch, .default, .else,
       // Return-like statements
-      .break, .continue, .fallthrough, .return, .throw, .then, .yield:
+      .break, .continue, .fallthrough, .return, .throw, .then, .yield,
+      // 'in' occurs in closure input/output definitions and for loops. Consider both constructs expression-like.
+      .in:
       self = .stmtKeyword
 
     // MARK: Decl keywords


Test patch:
diff --git a/Tests/SwiftParserTest/StatementTests.swift b/Tests/SwiftParserTest/StatementTests.swift
index 394e4af55ed..bd3f790bb75 100644
--- a/Tests/SwiftParserTest/StatementTests.swift
+++ b/Tests/SwiftParserTest/StatementTests.swift
@@ -921,4 +921,13 @@ final class StatementTests: ParserTestCase {
       """
     )
   }
+
+  func testForStatementWithUnexpectedTokenBeforeInKeyword() {
+    assertParse(
+      "for var elem1️⃣? in arr { }",
+      diagnostics: [
+        DiagnosticSpec(message: "unexpected code '?' in 'for' statement")
+      ]
+    )
+  }
 }
Repository: swift-server/swiftly (swift)

Issue:
Ensure swiftly can parse tags from apple/swift repository
swiftly currently can parse toolchain selectors of the form `a.b-DEVELOPMENT-SNAPSHOT-YYYY-mm-dd-a`, but tags at https://github.com/apple/swift/tags have a `swift-` prefix, which swiftly cannot parse. We should update the parsing to accept that so that users can easily install a toolchain based on a git tag.

Pull request:
Closes #69

Patch:
diff --git a/Sources/SwiftlyCore/ToolchainVerison.swift b/Sources/SwiftlyCore/ToolchainVerison.swift
index aeb21e1b..94e43cc9 100644
--- a/Sources/SwiftlyCore/ToolchainVerison.swift
+++ b/Sources/SwiftlyCore/ToolchainVerison.swift
@@ -324,7 +324,7 @@ struct StableReleaseParser: ToolchainSelectorParser {
     }
 }
 
-/// Parser for selectors like the following:
+/// Parser for selectors like the following (with optional "swift-" prefix):
 ///    - a.b-snapshot-YYYY-mm-dd
 ///    - a.b-snapshot
 ///    - a.b-DEVELOPMENT-SNAPSHOT-YYYY-mm-dd-a
@@ -334,7 +334,7 @@ struct StableReleaseParser: ToolchainSelectorParser {
 ///    - a.b-SNAPSHOT
 struct ReleaseSnapshotParser: ToolchainSelectorParser {
     static let regex: Regex<(Substring, Substring, Substring, Substring?)> =
-        try! Regex("^([0-9]+)\\.([0-9]+)-(?:snapshot|DEVELOPMENT-SNAPSHOT|SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
+        try! Regex("^(?:swift-)?([0-9]+)\\.([0-9]+)-(?:snapshot|DEVELOPMENT-SNAPSHOT|SNAPSHOT)(?:-([0-9]{4}-[0-9]{2}-[0-9]{2}))?(?:-a)?$")
 
     func parse(_ input: String) throws -> ToolchainSelector? {
         guard let match = try Self.regex.wholeMatch(in: input) else {


Test patch:
diff --git a/Tests/SwiftlyTests/ToolchainSelectorTests.swift b/Tests/SwiftlyTests/ToolchainSelectorTests.swift
index 5d675dd5..0332a31c 100644
--- a/Tests/SwiftlyTests/ToolchainSelectorTests.swift
+++ b/Tests/SwiftlyTests/ToolchainSelectorTests.swift
@@ -43,6 +43,9 @@ final class ToolchainSelectorTests: SwiftlyTests {
             "5.7-snapshot",
             "5.7-SNAPSHOT",
             "5.7-DEVELOPMENT-SNAPSHOT",
+            "swift-5.7-snapshot",
+            "swift-5.7-SNAPSHOT",
+            "swift-5.7-DEVELOPMENT-SNAPSHOT",
         ]
         try runTest(.snapshot(branch: .release(major: 5, minor: 7), date: nil), parses)
     }
@@ -53,6 +56,10 @@ final class ToolchainSelectorTests: SwiftlyTests {
             "5.7-SNAPSHOT-2023-06-05",
             "5.7-DEVELOPMENT-SNAPSHOT-2023-06-05",
             "5.7-DEVELOPMENT-SNAPSHOT-2023-06-05-a",
+            "swift-5.7-snapshot-2023-06-05",
+            "swift-5.7-SNAPSHOT-2023-06-05",
+            "swift-5.7-DEVELOPMENT-SNAPSHOT-2023-06-05",
+            "swift-5.7-DEVELOPMENT-SNAPSHOT-2023-06-05-a",
         ]
         try runTest(.snapshot(branch: .release(major: 5, minor: 7), date: "2023-06-05"), parses)
     }