@@ -1032,17 +1032,25 @@ void PatternMatchEmission::emitWildcardDispatch(ClauseMatrix &clauses,
1032
1032
assert (!hasGuard || !clauses[row].isIrrefutable ());
1033
1033
1034
1034
auto stmt = clauses[row].getClientData <CaseStmt>();
1035
- ArrayRef<CaseLabelItem> labelItems = stmt->getCaseLabelItems ();
1036
- bool hasMultipleItems = labelItems.size () > 1 ;
1035
+ bool hasMultipleItems = false ;
1036
+ if (stmt->getKind () == StmtKind::Case) {
1037
+ ArrayRef<CaseLabelItem> labelItems = stmt->getCaseLabelItems ();
1038
+ hasMultipleItems = labelItems.size () > 1 ;
1039
+ }
1037
1040
1038
1041
// Bind the rest of the patterns.
1039
1042
bindIrrefutablePatterns (clauses[row], args, !hasGuard, hasMultipleItems);
1040
1043
1041
1044
// Emit the guard branch, if it exists.
1042
1045
if (guardExpr) {
1043
- SGF.usingImplicitVariablesForPattern (clauses[row].getCasePattern (), stmt, [&]{
1044
- this ->emitGuardBranch (guardExpr, guardExpr, failure);
1045
- });
1046
+ if (stmt->getKind () == StmtKind::Case) {
1047
+ SGF.usingImplicitVariablesForPattern (clauses[row].getCasePattern (), stmt, [&]{
1048
+ this ->emitGuardBranch (guardExpr, guardExpr, failure);
1049
+ });
1050
+ } else {
1051
+ assert (stmt->getKind () == StmtKind::Catch);
1052
+ emitGuardBranch (guardExpr, guardExpr, failure);
1053
+ }
1046
1054
}
1047
1055
1048
1056
// Enter the row.
0 commit comments