@@ -786,8 +786,8 @@ extension JSONDecoderImpl: Decoder {
786
786
787
787
var iter = jsonMap. makeObjectIterator ( from: region. startOffset)
788
788
while let ( keyValue, value) = iter. next ( ) {
789
- // Failing to unwrap a string here is impossible, as scanning already guarantees that dictionary keys are strings .
790
- let key = try ! self . unwrapString ( from: keyValue, for: dictCodingPathNode, _CodingKey? . none)
789
+ // We know these values are keys, but UTF-8 decoding could still fail .
790
+ let key = try self . unwrapString ( from: keyValue, for: dictCodingPathNode, _CodingKey? . none)
791
791
let value = try self . unwrap ( value, as: dictType. elementType, for: dictCodingPathNode, _CodingKey ( stringValue: key) !)
792
792
result [ key] . _setIfNil ( to: value)
793
793
}
@@ -1202,14 +1202,14 @@ extension JSONDecoderImpl {
1202
1202
switch keyDecodingStrategy {
1203
1203
case . useDefaultKeys:
1204
1204
while let ( keyValue, value) = iter. next ( ) {
1205
- // Failing to unwrap a string here is impossible, as scanning already guarantees that dictionary keys are strings .
1206
- let key = try ! impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1205
+ // We know these values are keys, but UTF-8 decoding could still fail .
1206
+ let key = try impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1207
1207
result [ key] . _setIfNil ( to: value)
1208
1208
}
1209
1209
case . convertFromSnakeCase:
1210
1210
while let ( keyValue, value) = iter. next ( ) {
1211
- // Failing to unwrap a string here is impossible, as scanning already guarantees that dictionary keys are strings .
1212
- let key = try ! impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1211
+ // We know these values are keys, but UTF-8 decoding could still fail .
1212
+ let key = try impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1213
1213
1214
1214
// Convert the snake case keys in the container to camel case.
1215
1215
// If we hit a duplicate key after conversion, then we'll use the first one we saw.
@@ -1219,8 +1219,8 @@ extension JSONDecoderImpl {
1219
1219
case . custom( let converter) :
1220
1220
let codingPathForCustomConverter = codingPathNode. path
1221
1221
while let ( keyValue, value) = iter. next ( ) {
1222
- // Failing to unwrap a string here is impossible, as scanning already guarantees that dictionary keys are strings.
1223
- let key = try ! impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1222
+ // We know these values are keys, but UTF-8 decoding could still fail.
1223
+ let key = try impl. unwrapString ( from: keyValue, for: codingPathNode, _CodingKey? . none)
1224
1224
1225
1225
var pathForKey = codingPathForCustomConverter
1226
1226
pathForKey. append ( _CodingKey ( stringValue: key) !)
0 commit comments