mirror of
https://github.com/apple/swift.git
synced 2026-10-10 13:50:43 +02:00
In salvage(), there is a point where we're done solving, but we haven't yet torn down ConstraintSystem::solverState, so the trail is still active. It was possible to cause a change to be recorded, because of the path compression we do in TypeVariableType::getRepresentative(). We have a similar situation where we don't want to do path compression when we're looking up a type variable's representative in the middle of undo(). Generalize the existing UndoActive flag to Closed, and set it after solving in salvage() as well. While we're here, clean up an existing place where we would check isUndoActive() to not do that anymore, so now getRepresentative() is the only place that checks the state of the trail. A better cleanup would be to try to refactor or eliminate SolverState entirely, but this fix is pretty clean. Note that the test cases are somewhat random because the exact scenario is hard to trigger; you need to set up an invalid expression where the type variables are set up in just the right way so that path compression kicks in. - Fixes rdar://152143989. - Fixes https://github.com/swiftlang/swift/issues/81801. - Fixes https://github.com/swiftlang/swift/issues/84884.
10 lines
422 B
Swift
10 lines
422 B
Swift
// {"kind":"typecheck","original":"cbf69c52","signature":"swift::constraints::SolverTrail::~SolverTrail()","signatureAssert":"Assertion failed: (Changes.empty() && \"Trail corrupted\"), function ~SolverTrail","signatureNext":"ConstraintSystem::SolverState"}
|
|
// RUN: not %target-swift-frontend -typecheck %s
|
|
@propertyWrapper struct a<b> {
|
|
init(wrappedValue: a)
|
|
var wrappedValue: b
|
|
}
|
|
struct c {
|
|
@a @a var d: Int = 2
|
|
}
|