Skip to content

Commit d5b30ee

Browse files
committed
[ASTVerifier] Check the type of a TupleExpr, at least at a basic level. (#2261)
1 parent 792259a commit d5b30ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,19 @@ struct ASTNodeBase {};
836836
verifyCheckedBase(S);
837837
}
838838

839+
void verifyChecked(TupleExpr *E) {
840+
const TupleType *exprTy = E->getType()->castTo<TupleType>();
841+
for_each(exprTy->getElements().begin(), exprTy->getElements().end(),
842+
E->getElements().begin(),
843+
[this](const TupleTypeElt &field, const Expr *elt) {
844+
checkTrivialSubtype(field.getType()->getUnlabeledType(Ctx),
845+
elt->getType()->getUnlabeledType(Ctx),
846+
"tuple and element");
847+
});
848+
// FIXME: Check all the variadic elements.
849+
verifyCheckedBase(E);
850+
}
851+
839852
void verifyChecked(InOutExpr *E) {
840853
Type srcObj = checkLValue(E->getSubExpr()->getType(),
841854
"result of InOutExpr");

0 commit comments

Comments
 (0)