Skip to content

Commit ee532e7

Browse files
committed
[CS] Add null check for the pattern in SyntacticElementTarget::getSourceRange
For an external property wrapper, there may not be a pattern here. I believe this should only be hit during `-debug-constraints` or if there's a too complex error (which I'm not sure is possible to produce in this case), so no test.
1 parent 02c9008 commit ee532e7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

include/swift/Sema/SyntacticElementTarget.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,13 @@ class SyntacticElementTarget {
771771

772772
// For an initialization, include the pattern in the range too.
773773
if (isForInitialization()) {
774-
if (auto patternRange = getInitializationPattern()->getSourceRange()) {
775-
if (range.isInvalid()) {
776-
range = patternRange;
777-
} else {
778-
range.widen(patternRange);
774+
if (auto *pattern = getInitializationPattern()) {
775+
if (auto patternRange = pattern->getSourceRange()) {
776+
if (range.isInvalid()) {
777+
range = patternRange;
778+
} else {
779+
range.widen(patternRange);
780+
}
779781
}
780782
}
781783
}

0 commit comments

Comments
 (0)