You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumChoice: CaseIterable {
casea, b, c, d, e, f
}
// as show here, the closure can return tuple with any labelsletbitMap = Dictionary<Choice, Int>(uniqueKeysWithValues: Choice.allCases.enumerated().map {
// (key: $1, value: 1 << $0) // error: Initializer 'init(uniqueKeysWithValues:)' requires the types '(key: Choice, value: Int)' and '(Choice, Int)' be equivalent// (key: $1, value: $0) // !!! exact same tuple as above, now no problem!// not bit shift in second parameter, no problem no matter the tuple labels
(truck: $1, you: $0) // no matter what the labels are, all no problem!// ($1, 1 << $0) // this works
})
// but exactly the same as above, here get compile errorletbitMap2 = Dictionary<Choice, Int>(uniqueKeysWithValues: Choice.allCases.enumerated().map { // Initializer 'init(uniqueKeysWithValues:)' requires the types '(key: Choice, value: Int)' and '(Choice, Int)' be equivalent// bit shift 1 << $0 cause problem
(key: $1, value: 1 << $0) // <== because of this, shouldn't be a problem as shown up above
})
// small transform compile fineletbitMap3 = Dictionary<Choice, Int>(uniqueKeysWithValues: Choice.allCases.enumerated().map {
letn = 1 << $0return (key: $1, value: n) // <== because of this, shouldn't be a problem as shown up above
})
// also compileletbitMap4 = Dictionary<Choice, Int>(uniqueKeysWithValues: Choice.allCases.enumerated().map {
lett = (key: $1, value: 1 << $0)
returnt
})
Environment
Xcode Version 13.0 beta 5 (13A5212g)
Additional Detail from JIRA
md5: 724739de185acea36e472bb8d15e7473
Issue Description:
I think there should not be any compiler error:
See: https://forums.swift.org/t/tuple-key-choice-value-int-and-choice-int-not-equivalent/51192/4
The text was updated successfully, but these errors were encountered: