mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ConstraintSystem] Detect and fix extraneous use of &
Diagnose extraneous use of address of (`&`) which could only be
associated with arguments to `inout` parameters e.g.
```swift
struct S {}
var a: S = ...
var b: S = ...
a = &b
```
This commit is contained in:
@@ -2674,3 +2674,9 @@ bool InvalidMethodRefInKeyPath::diagnoseAsError() {
|
||||
getName(), isForKeyPathDynamicMemberLookup());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidUseOfAddressOf::diagnoseAsError() {
|
||||
auto *anchor = cast<AssignExpr>(getAnchor());
|
||||
emitDiagnostic(anchor->getSrc()->getLoc(), diag::extraneous_address_of);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user