Skip to content

Commit 0a0019b

Browse files
committed
Sema: Fix null pointer dereference with invalid ParamDecl
1 parent 0e1561f commit 0a0019b

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,13 +2248,20 @@ ParamSpecifierRequest::evaluate(Evaluator &evaluator,
22482248

22492249
auto typeRepr = param->getTypeRepr();
22502250

2251-
if (!typeRepr && !param->isImplicit()) {
2252-
// Untyped closure parameter.
2253-
return ParamSpecifier::Default;
2254-
}
2251+
if (!typeRepr) {
2252+
if (!param->isImplicit()) {
2253+
// Untyped closure parameter.
2254+
return ParamSpecifier::Default;
2255+
}
22552256

2256-
assert(typeRepr != nullptr && "Should call setSpecifier() on "
2257-
"synthesized parameter declarations");
2257+
if (param->isInvalid()) {
2258+
// Invalid parse.
2259+
return ParamSpecifier::Default;
2260+
}
2261+
2262+
ASSERT(false && "Should call setSpecifier() on "
2263+
"synthesized parameter declarations");
2264+
}
22582265

22592266
// Look through top-level pack expansions. These specifiers are
22602267
// part of what's repeated.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// {"signature":"swift::ParamSpecifierRequest::evaluate(swift::Evaluator&, swift::ParamDecl*) const"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
func a([0])

0 commit comments

Comments
 (0)