Skip to content

Commit e747dc2

Browse files
Resolve issues
1 parent 8d5a33e commit e747dc2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/Sema/CSGen.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,18 +1152,21 @@ namespace {
11521152
// `_ = nil`, let's diagnose it here because solver can't
11531153
// attempt any types for it.
11541154
auto *parentExpr = CS.getParentExpr(expr);
1155-
if (auto *PE = dyn_cast<ParenExpr>(parentExpr))
1155+
if (parentExpr && isa<ParenExpr>(parentExpr))
11561156
parentExpr = CS.getParentExpr(parentExpr);
11571157

1158-
if (isa<ForceValueExpr>(parentExpr)) {
1159-
DE.diagnose(expr->getLoc(), diag::cannot_force_unwrap_nil_literal);
1160-
return Type();
1161-
}
1158+
if (parentExpr) {
1159+
// `_ = nil!`
1160+
if (isa<ForceValueExpr>(parentExpr)) {
1161+
DE.diagnose(expr->getLoc(), diag::cannot_force_unwrap_nil_literal);
1162+
return Type();
1163+
}
11621164

1163-
if (isa<NilLiteralExpr>(parentExpr)
1164-
|| isa<OptionalEvaluationExpr>(parentExpr)) {
1165-
DE.diagnose(expr->getLoc(), diag::unresolved_nil_literal);
1166-
return Type();
1165+
// `_ = nil?`
1166+
if (isa<OptionalEvaluationExpr>(parentExpr)) {
1167+
DE.diagnose(expr->getLoc(), diag::unresolved_nil_literal);
1168+
return Type();
1169+
}
11671170
}
11681171

11691172
// `_ = nil`

0 commit comments

Comments
 (0)