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
$ jw-docker-swift-5.5 swift test.swift
{"dict":[{"x":"a"},"a"]}
Something(dict: [test.Something.Key(x: "a"): "a"])
{"dict":{}}
ERRROR: typeMismatch(Swift.Array<Foundation.JSONValue>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "dict", intValue: nil)], debugDescription: "Expected to decode Array<JSONValue> but found a dictionary instead.", underlyingError: nil))
note how
1. the encoding of the empty dictionary becomes {} and not [] anymore.
2. how the decoder can't decode it
Linux main (from today)
$ jw-docker-swift-main swift test.swift
docker.io/swiftlang/swift:nightly-main
{"dict":[{"x":"a"},"a"]}
Something(dict: [test.Something.Key(x: "a"): "a"])
{"dict":{}}
ERRROR: typeMismatch(Swift.Array<Foundation.JSONValue>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "dict", intValue: nil)], debugDescription: "Expected to decode Array<JSONValue> but found a dictionary instead.", underlyingError: nil))
$ jw-docker-swift-main swift -version
docker.io/swiftlang/swift:nightly-main
Swift version 5.6-dev (LLVM 7b20e61dd04138a, Swift 9438cf6b2e83c5f)
Target: x86_64-unknown-linux-gnu
is also affected
The text was updated successfully, but these errors were encountered:
Environment
5.5 (swift-5.5-RELEASE)
Additional Detail from JIRA
md5: c76d56c48a3626a6da4c743bc9592a1b
Issue Description:
This is a very severe bug that will affect any Swift software that encodes any dictionary whose keys aren't
StringorInt.JSONDecoderwill error on values produces byJSONEncoderfor the empty Dictionary.Consider this repro:
Darwin
which is correct. Note how the empty dictionary gets encoded as
[]in JSON.Linux Swift 5.4
same result, correct.
Linux 5.5
note how
1. the encoding of the empty dictionary becomes {} and not [] anymore.
2. how the decoder can't decode it
Linux main (from today)
is also affected
The text was updated successfully, but these errors were encountered: