swift
4c7e4615 - Improve captured field diagnostics

Commit
3 years ago
Improve captured field diagnostics This patch improves the error message emitted when the capture list contains an item that is a sub-field of a struct/class/etc.... If the closure capture did not include `weak` at the beginning, the presence of a period would cause the if-chain to fall through the identifier checking, resulting in an error message about expecting a `weak` keyword. Instead, I've opted to accept the period at that stage of parsing so that we can fall through to a better error message. For the following code ``` { [self.field] in ... } ``` instead of emitting `expected 'weak', 'unowned', or no specifier in capture list`, we now emit `fields may only be captured by assigning to a specific name` with a fix-it that changes the code to ``` { [ field = self.field ] in ... } ```
Author
Committer
Parents
Loading