Skip to content

Add an Assert To Make Sure the SIL Parser Emits Diagnostics #34701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ ParseSILModuleRequest::evaluate(Evaluator &evaluator,
if (hadError) {
// The rest of the SIL pipeline expects well-formed SIL, so if we encounter
// a parsing error, just return an empty SIL module.
//
// Because the SIL parser's notion of failing with an error is distinct from
// the ASTContext's notion of having emitted a diagnostic, it's possible for
// the parser to fail silently without emitting a diagnostic. This assertion
// ensures that +asserts builds will fail fast. If you crash here, please go
// back and add a diagnostic after identifying where the SIL parser failed.
assert(SF->getASTContext().hadError() &&
"Failed to parse SIL but did not emit any errors!");
return SILModule::createEmptyModule(desc.context, desc.conv, desc.opts);
}
return silMod;
Expand Down