-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeChecker] Always emit a fallback error if type-check failed witho… #21517
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
Conversation
Can we add a test for this by adding some special kind of Expr or Builtin call that fails in the solver but CSDiag intentionally does not emit an error for? |
Sure, it seems like the only way to go trying to test this. |
Added |
@swift-ci please test |
Build failed |
Build failed |
Slightly edited comment in |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test source compatibility |
@swift-ci please test |
/cc @DougGregor @rudkx Could you guys please take a look? |
Build failed |
Build failed |
// Before producing fatal error here, let's check if there are any "error" | ||
// diagnostics already emitted or waiting to be emitted. Because they are | ||
// a better indication of the problem. | ||
if (!(hadAnyErrors() || TC.Context.hasDelayedConformanceErrors())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm confused as to why we have both the TC.Context.hasDelayedConformanceErrors()
check and the specific isInvalid()
checks above. Doesn't this one suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the situation I came up with was - solution application failed without diagnostic and it was unrelated to invalid conformances in the current expression, but we already had errors like that record by previous expressions so instead of producing fatal error here, let's just keep going since when delayed conformances are processed they are going to produce one or more errors anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay!
…ut producing one Sometimes constraint solver fails without producing any diagnostics, it could happen during different phases e.g. pre-check, constraint generation, or even while attempting to apply solution. Such behavior leads to crashes down the line in AST Verifier or SILGen which are hard to diagnose. Let's guard against that by tracking if solver produced any diagnostics upon its failure and if no errors were or are scheduled to be produced, let's produce a fallback fatal error pointing at affected expression. Resolves: rdar://problem/38885760
* Incomplete conformance is not necessarily going to produce a diagnostic * Use `userFacingName` to avoid assert related to special names.
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test source compatibility |
…ut producing one
Sometimes constraint solver fails without producing any diagnostics,
it could happen during different phases e.g. pre-check, constraint
generation, or even while attempting to apply solution. Such behavior
leads to crashes down the line in AST Verifier or SILGen which are
hard to diagnose.
Let's guard against that by tracking if solver produced any diagnostics
upon its failure and if no errors were or are scheduled to be produced,
let's produce a fallback fatal error pointing at affected expression.
Resolves: rdar://problem/38885760