Open
Description
Previous ID | SR-7222 |
Radar | rdar://problem/38624846 |
Original Reporter | valleyman86 (JIRA User) |
Type | Bug |
Environment
Xcode 9.3 beta 4 Swift 4.1
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler, Standard Library |
Labels | Bug, 4.1Regression, RunTimeCrash |
Assignee | None |
Priority | Medium |
md5: 8861114e1b1eac9fc303c01bd4786968
Issue Description:
enum PlaydoughConfigView {
case header
case subtitle
case art
case progress
case controls
case bannerAds
}
enum PlaydoughConfig {
case standard
case basic
case compactStandard
case compactBasic
}
extension PlaydoughConfig: RawRepresentable {
typealias RawValue = [PlaydoughConfigView]
static let configs = [.standard: [.header, .art, .subtitle, .progress, .controls, .bannerAds],
.basic: [.header, .art, .subtitle, .progress, .controls],
.compactStandard: [.header, .art, .progress, .controls, .bannerAds],
.compactBasic: [.header, .art, .progress, .controls]] as [PlaydoughConfig: RawValue]
init?(rawValue: RawValue) {
if let key = PlaydoughConfig.configs.first(where: { rawValue == $1 })?.key {
self = key
}
return nil
}
var rawValue: RawValue {
return PlaydoughConfig.configs[self] ?? []
}
}
let test = PlaydoughConfig.configs[.standard] // Crash
This is a regression from Swift 4.0. It seems the Dictionary.init is calling rawValue most likely due to equatable. This code works fine in 4.0 and crashes in 4.1.