Skip to content

Commit 3b23723

Browse files
authored
Merge pull request swiftlang#37421 from ahoppen/pr/fix-crash-complete-in-result-builder-with-nil
[CodeComplete] Fix crash when completing inside a result builder containing a variable initialized with `nil`
2 parents f832153 + ad5dc2d commit 3b23723

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4718,6 +4718,9 @@ bool constraints::isStandardComparisonOperator(ASTNode node) {
47184718
Optional<std::pair<Expr *, unsigned>>
47194719
ConstraintSystem::isArgumentExpr(Expr *expr) {
47204720
auto *argList = getParentExpr(expr);
4721+
if (!argList) {
4722+
return None;
4723+
}
47214724

47224725
if (isa<ParenExpr>(argList)) {
47234726
for (;;) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename=%s
2+
3+
@resultBuilder
4+
struct TupleBuilder<T> {
5+
static func buildBlock() -> () { }
6+
}
7+
8+
func testPatternMatching() {
9+
@TupleBuilder<String> var x3 {
10+
let x: Int? = nil
11+
#^COMPLETE^#
12+
}
13+
}

0 commit comments

Comments
 (0)