Why is CodingUserInfoKey's rawValue initializer failable?

I have some code like this:

extension SomeType: Decodable {
    private static let someKey = CodingUserInfoKey(rawValue: "SomeType.someKey")!

    static func decoder(value: SomeNecessaryValueForDecoding) -> JSONDecoder {
        let decoder = JSONDecoder()
        decoder.userInfo = [
            SomeType.someKey: value,
        return decoder

As far as I can tell, this will never actually fail. Is there a reason the initializer is failable? Maybe there's a non-failable initializer I've missed, or something I'm generally misunderstanding about this type?

This was largely a mistake in the implementation; please see SR-6753 for background. This is something that might be fixable, keeping in mind source stability requirements.

Terms of Service

Privacy Policy

Cookie Policy