[ConstraintSystem] Detect and diagnose extraneous returns from void functions

Diagnose an attempt return something from a function which
doesn't have a return type specified e.g.

```swift
func foo() { return 42 }
```
This commit is contained in:
Pavel Yaskevich
2019-05-07 13:43:14 -07:00
parent 6cd476be47
commit 4f63c4af71
6 changed files with 57 additions and 1 deletions

View File

@@ -2733,3 +2733,9 @@ bool InvalidUseOfAddressOf::diagnoseAsError() {
emitDiagnostic(anchor->getSrc()->getLoc(), diag::extraneous_address_of);
return true;
}
bool ExtraneousReturnFailure::diagnoseAsError() {
auto *anchor = getAnchor();
emitDiagnostic(anchor->getLoc(), diag::cannot_return_value_from_void_func);
return true;
}