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
[SR-13364] keypath missing optional crashes compiler: "Inactive constraints left over?" #55805
Comments
The corrected keypath literal does not crash the compiler:
|
Just reproduced on a near master |
@swift-ci create |
@xedin @hamishknight @hborla I was taking a look at that and the problem seems to be related to the fact the value is optional `Int` so the solver is not able to find a binding for that and the result is a system with an unresolved KeyPath constraint, therefore, a crash. I kinda fix by marking the keypath type var fully bound, allowing the solver to wait until root and value(in this case rvalueBase) so we are able to find the optional binding for the key path value and resolve key path constraint. But that seems to cause a regression in a specific test-case swift/test/Constraints/rdar62201037.swift Line 28 in 782863c
So my question would be if you think that is indeed the problem and we are at least in the right direction, or am I missing something? |
@LucianoPAlmeida Sorry for the delayed response! If I recall correctly, the problem here is that an overload type variable is being bound (from the context) before the overload is being resolved, leaving the key path constraint unsolved. This is because key path constraints currently rely on overloads being resolved when they get bound (as this triggers the re-activation of the constraint, and the key path needs to dig out the overload choice). The proper solution to this would be to re-design how we solve key-path constraints. Ideally we would have it so the key path component validation and concrete key path type inference logic only gets run when the last overload in the chain is resolved, and we would have a proper way of propagating the root type of the path from the context without relying on obtaining it from the constraint system's contextual type (which would solve e.g SR-8383). I was going to have a crack at this, but never got round to it – I'd be happy to answer any questions if you want to take it on! I believe @xedin has also had some thoughts on how to re-do key path solving and may be able to help. |
@hamishknight No worries, thanks for the explanation. |
Fixed by #36427 Please use next available main branch snapshot to verify. |
Additional Detail from JIRA
md5: 71e5c011ff187bd9e90ed4a902b8b2af
is duplicated by:
Issue Description:
Here's the test case:
Here's the crash with Xcode 12 beta 4's toolchain:
The text was updated successfully, but these errors were encountered: