CompilerStack has a lot of checks for things that are never meant to happen and do not need a user-facing validation. We normally enforce such expectations with assertions, because violating them is a bug, not a compilation error.
This has been bothering me for a long time, but became especially annoying now when I was reviewing #15168 and needed to figure out what kinds of runtime exceptions we throw and when.
I also fixed two somewhat related things:
Several cases of InternalCompilerError being thrown directly rather than as a result of a failed assert.
Several cases of unexpected FatalError being rethrown rather than immediately handled as a violated assumption. Now it's an ICE and the assert makes it clear that it's unexpected, not requiring extra comments.
CompilerStack
has a lot of checks for things that are never meant to happen and do not need a user-facing validation. We normally enforce such expectations with assertions, because violating them is a bug, not a compilation error.This has been bothering me for a long time, but became especially annoying now when I was reviewing #15168 and needed to figure out what kinds of runtime exceptions we throw and when.
I also fixed two somewhat related things:
InternalCompilerError
being thrown directly rather than as a result of a failed assert.FatalError
being rethrown rather than immediately handled as a violated assumption. Now it's an ICE and the assert makes it clear that it's unexpected, not requiring extra comments.