swiftlang / swiftlang/swift-syntax
Lookahead/parse mismatch: canParseClosureSignature accepts top-level '->' but signature parse fails (missing 'in')
- Dominant language
- Swift
- Stars
- 3.7k
- Forks
- 553
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 16
Description
### Issue Kind
Bad Diagnostic Produced
### Source Code
```swift
struct Foo {
func a(s: S [{{g) -> Int {}
}}}
```
### Description
Following #3162, the following code in function [testRecovery141 ](https://github.com/swiftlang/swift-syntax/blob/a113ef952acc8423b91d0d112a84497db6538611/Tests/SwiftParserTest/translated/RecoveryTests.swift#L2427) of [RecoveryTests](https://github.com/swiftlang/swift-syntax/blob/main/Tests/SwiftParserTest/translated/RecoveryTests.swift#L2427) gives the following diagnostics: "expected 'in' in closure signature" at the arrow location, and "unexpected code ') -> Int {}' in closure". However, lookahead shouldn't accept a closure signature here, or the parse should consume consistently, instead of having a mismatch between lookahead and the actual parse.
Contributor guide
Assessment
This issue has not been assessed yet.