File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -121,10 +121,16 @@ class FindLocalVal : public StmtVisitor<FindLocalVal> {
121
121
}
122
122
123
123
void checkStmtCondition (const StmtCondition &Cond) {
124
- for (auto entry : Cond)
125
- if (auto *P = entry.getPatternOrNull ())
126
- if (!isReferencePointInRange (entry.getSourceRange ()))
124
+ SourceLoc start = SourceLoc ();
125
+ for (auto entry : Cond) {
126
+ if (start.isInvalid ())
127
+ start = entry.getStartLoc ();
128
+ if (auto *P = entry.getPatternOrNull ()) {
129
+ SourceRange previousConditionsToHere = SourceRange (start, entry.getEndLoc ());
130
+ if (!isReferencePointInRange (previousConditionsToHere))
127
131
checkPattern (P, DeclVisibilityKind::LocalVariable);
132
+ }
133
+ }
128
134
}
129
135
130
136
void visitIfStmt (IfStmt *S) {
Original file line number Diff line number Diff line change @@ -566,3 +566,9 @@ func foo1() {
566
566
_ = MyGenericEnum< Int> . One // expected-error {{enum type 'MyGenericEnum<Int>' has no case 'One'; did you mean 'one'}}{{26-29=one}}
567
567
_ = MyGenericEnum< Int> . OneTwo // expected-error {{enum type 'MyGenericEnum<Int>' has no case 'OneTwo'; did you mean 'oneTwo'}}{{26-32=oneTwo}}
568
568
}
569
+
570
+ // SR-4082
571
+ func foo2( ) {
572
+ let x = 5
573
+ if x < 0 , let x = Optional ( 1 ) { } // expected-warning {{immutable value 'x' was never used; consider replacing with '_' or removing it}}
574
+ }
You can’t perform that action at this time.
0 commit comments