Skip to content

Commit 3a28a52

Browse files
committed
[AST] Enforce that ParenExpr is typed as ParenType
Make sure we don't accidentally drop the sugar of the type.
1 parent 28f5c57 commit 3a28a52

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,15 @@ class Verifier : public ASTWalker {
20082008
verifyCheckedBase(E);
20092009
}
20102010

2011+
void verifyChecked(ParenExpr *E) {
2012+
PrettyStackTraceExpr debugStack(Ctx, "verifying ParenExpr", E);
2013+
if (!isa<ParenType>(E->getType().getPointer())) {
2014+
Out << "ParenExpr not of ParenType\n";
2015+
abort();
2016+
}
2017+
verifyCheckedBase(E);
2018+
}
2019+
20112020
void verifyChecked(AnyTryExpr *E) {
20122021
PrettyStackTraceExpr debugStack(Ctx, "verifying AnyTryExpr", E);
20132022

test/expr/closure/nested_inner_closures.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ assert({ () -> Bool in
55
}(), "")
66

77
var x = ({ () -> String in return "s" })()
8+
var y = ((({ () -> String in return "s" })))()

0 commit comments

Comments
 (0)