mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user