Fix a Simple Crash-On-Invalid For @_spi

The parser attempts to recover here by producing a broken VarDecl with
no parent pattern. The DeclChecker sees this when trying to install
a default initializer in the linked regression test and crashes because
it tries to look into a null parent pattern.

rdar://74154023
This commit is contained in:
Robert Widmann
2021-02-09 12:36:46 -08:00
parent 22acb2fc9f
commit 013127a947
2 changed files with 14 additions and 0 deletions

View File

@@ -147,6 +147,11 @@ static void maybeAddMemberwiseDefaultArg(ParamDecl *arg, VarDecl *var,
if (var->isLet())
return;
// If there's no parent pattern there's not enough structure to even perform
// this analysis. Just bail.
if (!var->getParentPattern())
return;
// We can only provide default values for patterns binding a single variable.
// i.e. var (a, b) = getSomeTuple() is not allowed.
if (!var->getParentPattern()->getSingleVar())