Skip to content

Commit 42bbbcb

Browse files
authored
Merge pull request #37453 from ahoppen/pr-5.5/fix-crash-complete-in-result-builder-with-nil
[5.5][CodeComplete] Fix crash when completing inside a result builder containing a variable initialized with `nil`
2 parents 3e61fad + a9160f6 commit 42bbbcb

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
@@ -4733,6 +4733,9 @@ bool constraints::isStandardComparisonOperator(ASTNode node) {
47334733
Optional<std::pair<Expr *, unsigned>>
47344734
ConstraintSystem::isArgumentExpr(Expr *expr) {
47354735
auto *argList = getParentExpr(expr);
4736+
if (!argList) {
4737+
return None;
4738+
}
47364739

47374740
if (isa<ParenExpr>(argList)) {
47384741
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)