Skip to content

Commit 1b0f3de

Browse files
committed
[AST] Ensure that type-checked Patterns always have types set
Kind of amazed we don't already have this. Add an ASTVerifier assertion to ensure type-checked patterns always have types set.
1 parent d56f463 commit 1b0f3de

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class Verifier : public ASTWalker {
486486
return true;
487487
}
488488
bool shouldVerifyChecked(Stmt *S) { return true; }
489-
bool shouldVerifyChecked(Pattern *S) { return S->hasType(); }
489+
bool shouldVerifyChecked(Pattern *S) { return true; }
490490
bool shouldVerifyChecked(Decl *S) { return true; }
491491

492492
// Only verify functions if they have bodies we can safely walk.
@@ -582,8 +582,14 @@ class Verifier : public ASTWalker {
582582
return;
583583
}
584584
}
585+
void verifyChecked(Pattern *P) {
586+
if (!P->hasType()) {
587+
Out << "pattern has no type\n";
588+
P->dump(Out);
589+
abort();
590+
}
591+
}
585592
void verifyChecked(Stmt *S) {}
586-
void verifyChecked(Pattern *P) { }
587593
void verifyChecked(Decl *D) {}
588594

589595
void verifyChecked(Type type) {

0 commit comments

Comments
 (0)