Skip to content

Commit 3ca91b5

Browse files
authored
Merge pull request #81130 from atrick/62-fix-default-init
[6.2] LifetimeDependence: fix a type checker crash on implicit init
2 parents 1dda72d + baa02e0 commit 3ca91b5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/AST/LifetimeDependence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ class LifetimeDependenceChecker {
962962
diagnose(returnLoc,
963963
diag::lifetime_dependence_cannot_infer_scope_ownership,
964964
param->getParameterName().str(), diagnosticQualifier());
965-
continue;
965+
return;
966966
}
967967
targetDeps = std::move(targetDeps).add(paramIndex, *kind);
968968
}

test/Sema/lifetime_depend_infer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ struct EscapableNonTrivialSelf {
168168
// (for initializers and stand-alone functions)
169169
// =============================================================================
170170

171+
// An implicit initializer illegally consumes its nontrivial parameter.
172+
public struct NonescapableImplicitInitializer: ~Escapable {
173+
// expected-error @-1{{cannot borrow the lifetime of 'c', which has consuming ownership on an implicit initializer}}
174+
var c: C
175+
}
176+
171177
struct NonescapableInitializers: ~Escapable {
172178
var c: C
173179

0 commit comments

Comments
 (0)