mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user