Skip to content

Commit 54a8a86

Browse files
authored
Merge pull request #82596 from hamishknight/solve-escape
[CS] Fix a couple of use-after-frees
2 parents a88c5ca + e912eeb commit 54a8a86

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
116116
} else if (!type->is<PackType>())
117117
type = PackType::getSingletonPackExpansion(type);
118118
}
119-
replacementTypes.push_back(type);
119+
replacementTypes.push_back(simplifyType(type));
120120
}
121121

122122
auto lookupConformanceFn =
@@ -146,9 +146,9 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
146146
return conformance;
147147
};
148148

149-
return SubstitutionMap::get(sig,
150-
replacementTypes,
151-
lookupConformanceFn);
149+
auto subs = SubstitutionMap::get(sig, replacementTypes, lookupConformanceFn);
150+
ASSERT(!subs.getRecursiveProperties().isSolverAllocated());
151+
return subs;
152152
}
153153

154154
// Lazily instantiate function definitions for class template specializations.

lib/Sema/CSDiagnostics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3880,7 +3880,8 @@ bool NonOptionalUnwrapFailure::diagnoseAsError() {
38803880
diagnostic = diag::invalid_force_unwrap;
38813881

38823882
auto range = getSourceRange();
3883-
emitDiagnostic(diagnostic, BaseType).highlight(range).fixItRemove(range.End);
3883+
emitDiagnostic(diagnostic, resolveType(BaseType))
3884+
.highlight(range).fixItRemove(range.End);
38843885
return true;
38853886
}
38863887

test/Constraints/rdar154553285.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift -disable-experimental-parser-round-trip
2+
3+
// Make sure we don't crash
4+
func testInvalidInInterpolation(_ x: Int) {
5+
_ = "\((x, \[]))" // expected-error {{invalid component of Swift key path}}
6+
}

validation-test/compiler_crashers_2/b33dbab8ed3643.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// {"signature":"swift::ProtocolConformanceRef::forAbstract(swift::Type, swift::ProtocolDecl*)"}
2-
// RUN: env DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib not --crash %target-swift-frontend -typecheck %s
3-
// REQUIRES: OS=macosx
4-
// REQUIRES: target-same-as-host
5-
// REQUIRES: no_asan
2+
// RUN: not %target-swift-frontend -typecheck %s
63
var sixDoubles
74
: Double "six has the value [\( ( sixDoubles \[]) }0 \0\0 \0 \sixDoubles)"

validation-test/compiler_crashers_2/89bcf379b8d4d092.swift renamed to validation-test/compiler_crashers_2_fixed/89bcf379b8d4d092.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"signature":"swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, std::__1::optional<swift::ASTExtInfo>)"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
struct a < b : FixedWidthInteger extension a : Sequence {
44
c {
55
{ for
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// {"signature":"swift::TypeBase::computeCanonicalType()"}
2+
// RUN: not %target-swift-frontend -typecheck %s
3+
func a (Int -> Int = { $0 func b( () = {}? ) func b {
4+
/ 1

0 commit comments

Comments
 (0)