Skip to content

Commit e4e6684

Browse files
authored
Merge pull request swiftlang#32608 from hborla/5.3-function-builder-csgen-failure
[5.3][Function Builders] Fix a function builder crash due to constraint generation failures
2 parents 7323cab + f46d14f commit e4e6684

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,10 @@ class BuilderClosureVisitor
283283
auto target = SolutionApplicationTarget::forInitialization(
284284
patternBinding->getInit(index), dc, patternType, pattern,
285285
/*bindPatternVarsOneWay=*/true);
286-
if (cs->generateConstraints(target, FreeTypeVariableBinding::Disallow))
286+
if (cs->generateConstraints(target, FreeTypeVariableBinding::Disallow)) {
287+
hadError = true;
287288
continue;
289+
}
288290

289291
// Keep track of this binding entry.
290292
applied.patternBindingEntries.insert({{patternBinding, index}, target});

test/Constraints/function_builder_diags.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,14 @@ func testNonExhaustiveSwitch(e: E) {
418418
// rdar://problem/59856491
419419
struct TestConstraintGenerationErrors {
420420
@TupleBuilder var buildTupleFnBody: String {
421+
let a = nil // expected-error {{'nil' requires a contextual type}}
421422
String(nothing) // expected-error {{cannot find 'nothing' in scope}}
422423
}
423424

424425
func buildTupleClosure() {
425-
tuplify(true) { _ in
426+
// FIXME: suppress the ambiguity error
427+
tuplify(true) { _ in // expected-error {{type of expression is ambiguous without more context}}
428+
let a = nothing // expected-error {{cannot find 'nothing' in scope}}
426429
String(nothing) // expected-error {{cannot find 'nothing' in scope}}
427430
}
428431
}

0 commit comments

Comments
 (0)