Skip to content

Commit 9a0f18b

Browse files
committed
Check maxSize on finish
1 parent a5de58d commit 9a0f18b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,14 +4108,20 @@ internal struct ValidatingInstantiateKeyPathBuffer: KeyPathPatternVisitor {
41084108
sizeVisitor.finish()
41094109
instantiateVisitor.finish()
41104110
isPureStruct.append(contentsOf: instantiateVisitor.isPureStruct)
4111-
checkSizeConsistency()
4111+
checkSizeConsistency(checkMaxSize: true)
41124112
}
41134113

4114-
func checkSizeConsistency() {
4114+
func checkSizeConsistency(checkMaxSize: Bool = false) {
41154115
let nextDest = instantiateVisitor.destData.baseAddress._unsafelyUnwrappedUnchecked
41164116
let curSize = nextDest - origDest + MemoryLayout<Int>.size
41174117

4118-
_internalInvariant(curSize == sizeVisitor.sizeWithMaxSize,
4118+
let sizeVisitorSize = if checkMaxSize {
4119+
sizeVisitor.sizeWithMaxSize
4120+
} else {
4121+
sizeVisitor.size
4122+
}
4123+
4124+
_internalInvariant(curSize == sizeVisitorSize,
41194125
"size and instantiation visitors out of sync")
41204126
}
41214127
}

0 commit comments

Comments
 (0)