-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
Getting a compiler bug error 'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug
. It is unclear what value the compiler does not support. Also in the playground the behaviour is slightly different. In the real app the second consume (consume allPins
) sometimes compiles.
Reproduction
struct PinnedInfo {
var hasPinnedCells: Bool {
return !allPins.isEmpty
}
var allPins: ContiguousArray<Int>
init(allPins: ContiguousArray<Int> = []) {
self.allPins = allPins
}
}
enum ModelState: Hashable, CaseIterable {
case initial
case modified
}
struct Storage<Model> {
var initial: Model?
var modified: Model?
mutating func setStorage(_ storage: Model, at state: ModelState) {
switch state {
case .initial:
initial = storage
case .modified:
modified = storage
}
}
}
var storagePinInfo = Storage<PinnedInfo>()
var storageAllPins = Storage<Array<Int>>()
var pinInfo = PinnedInfo(allPins: [])
var allPins = Array(repeating: 0, count: 100)
storagePinInfo.setStorage(consume pinInfo, at: .initial) // 'consume' applied to value that the compiler does not support
storageAllPins.setStorage(consume allPins, at: .initial) // 'consume' applied to value that the compiler does not support
Expected behavior
Correct consumption without COW. Or at least the proper explanation.
Environment
Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labelsThis issue needs more specific labels