Commit Graph

5 Commits

Author SHA1 Message Date
Alex Hoppen
bfc68f48e4 [Parser] When recovering from expression parsing don't stop at '{'
When recovering from a parser error in an expression, we resumed parsing at a '{'. I assume this was because we wanted to continue inside e.g. an if-body if parsing the condition failed, but it's actually causing more issue because when parsing e.g.

```swift
expr + has - error +

functionTakesClosure {
}
```

we continue parsing at the `{` of the trailing closure, which is a completely garbage location to continue parsing.

The motivating example for this change was (in a result builder)
```swift
Text("\(island.#^COMPLETE^#)")
takeTrailingClosure {}
```

Here `Text(…)` has an error (because it contains a code completion token) and thus we skip `takeTrailingClosure`, effectively parsing
```swift
Text(….) {}
```

which the type checker wasn’t very happy with and thus refused to provide code completion. With this change, we completely drop `takeTrailingClosure {}`. The type checker is a lot happier with that.
2022-04-07 09:19:22 +02:00
Hamish Knight
84a2c5c2c1 [Sema] Improve extra trailing closure diagnostic
Emit the specialized extraneous trailing closure
diagnostic for multiple trailing closures and
unlabelled unary argument lists, and add a
specialized trailing closure version for the multiple
extraneous case.
2021-08-02 12:59:43 +01:00
Hamish Knight
7d6dac6855 [Sema] Correct label fix-its for multiple trailing closures
Update the logic to account for multiple trailing
closures.

rdar://81278194
2021-08-02 12:59:43 +01:00
Hamish Knight
51535fc871 [test] Convert a couple of lines to use column matching 2021-08-02 12:59:42 +01:00
Hongjing
58a8b7521b SR-14221: Add tricky parsing test case for trailing closure (#36202)
Add test case for trailing closure.

Fixes SR-14221, fixes rdar://74366546
2021-03-04 10:48:22 -08:00