-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[PreCheckExpr] Allow pack references when resolving types during TypeExpr
folding.
#64105
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
@swift-ci please smoke test |
…ull type if the constraint system has not recorded a type for an expanded pack element type repr.
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
1 similar comment
@swift-ci please smoke test macOS |
// expressions. Some invalid code won't make it there, and | ||
// the constraint system won't have recorded a type. | ||
if (!CS.hasType(elementType->getPackType())) | ||
return Type(); |
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.
Github doesn’t like when comments appear directly on commit apparently…
Aborting here is not ideal for closure contexts because it fails the closure without diagnostic, we should record invalid reference or similar fix and produce a placeholder type just like we do for ErrorExprs…
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.
This happens when type resolution fails earlier than getting to each T
type reprs when they're nested, so a diagnostic has already been produced. I've fixed the other cases where pre-check was failing.
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 can address your suggestion later, but it'll need a little more work than allowing the type variable to bind to a hole, because this type needs to bind to a pack. This means we'll also need to teach ShapeOf
constraints to gracefully handle hole types without propagating errors, etc. But for right now, this change fixes a crash-on-invalid, and the type resolution error + unable to infer closure type
is a big improvement already.
How about we file a GitHub issue to track that change so we don't forget about it?
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.
a diagnostic has already been produced
This is a big problem in closure contexts currently because the diagnostic is produced mid-solving and unbeknownst to the solver so it’s really hard to reason about, we have this invalid reference fix which effectively lies that it produced a diagnostic (another point is that code completion depends on solver not failing early more and more now). We should try and avoid adding more cases like that if possible, fixing it separately sounds good to me!
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.
Filed #64109!
Pre-check should always allow pack references during
TypeExpr
folding. CSGen will diagnose cases that appear outside of pack expansion expressions.