Skip to content

Commit a72ea64

Browse files
Handle nil with any number of parentheses
1 parent faec586 commit a72ea64

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,11 @@ 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 (parentExpr && isa<ParenExpr>(parentExpr))
1155+
1156+
// Loop until you have an expr without parentheses
1157+
// so if you have (nil), ((nil)), (((nil))), etc...
1158+
// you get `nil`
1159+
while (parentExpr && isa<ParenExpr>(parentExpr))
11561160
parentExpr = CS.getParentExpr(parentExpr);
11571161

11581162
if (parentExpr) {

0 commit comments

Comments
 (0)