Files
swift-mirror/test/SILOptimizer/simplify_keypath_resilient.swift
Erik Eckstein 2962474b58 SimplifyKeyPath: insert the correct destroy operation for an operand of a removed keypath
If the operand is an address, we need to use `destroy_addr` and not `destroy_value`.

Fixes a compiler crash.
rdar://144662171
2025-02-12 08:35:23 +01:00

22 lines
521 B
Swift

// RUN: %target-swift-frontend -primary-file %s -enable-library-evolution -emit-sil | %FileCheck %s
public enum E: Hashable {
case e
}
public struct S {
public var dict: [E: Int] = [:]
}
// Check that the keypath simplification does not crash when inserting a compensating destroy.
// CHECK-LABEL: sil @$s26simplify_keypath_resilient6testityyF :
// CHECK-NOT: keypath
// CHECK: } // end sil function '$s26simplify_keypath_resilient6testityyF'
@inlinable
public func testit() {
let _ = \S.dict[.e]
}