Skip to content

Commit e713c42

Browse files
committed
Fall back to the AssignExprs startLoc when the EqualLoc is invalid
SIL Location diagnostics point at the getLoc, so when the EqualLoc is invalid we get no loc, while the startLoc is a fine alternative for these types of diagnostics.
1 parent ac57b66 commit e713c42

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/swift/AST/Expr.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -4331,7 +4331,13 @@ class AssignExpr : public Expr {
43314331

43324332
SourceLoc getEqualLoc() const { return EqualLoc; }
43334333

4334-
SourceLoc getLoc() const { return EqualLoc; }
4334+
SourceLoc getLoc() const {
4335+
SourceLoc loc = EqualLoc;
4336+
if (loc.isValid()) {
4337+
return loc;
4338+
}
4339+
return getStartLoc();
4340+
}
43354341
SourceLoc getStartLoc() const {
43364342
if (!isFolded()) return EqualLoc;
43374343
return ( Dest->getStartLoc().isValid()

0 commit comments

Comments
 (0)