Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Library/Serialization/Decoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension XCJSON {
let oldPath = currentPath; defer {
currentPath = oldPath
}
let oldCurrentValue = value; defer {
let oldCurrentValue = currentValue; defer {
currentValue = oldCurrentValue
}
let newPath = AbsolutePath(parent: oldPath, component: pathComponent)
Expand Down
27 changes: 27 additions & 0 deletions Sources/Tests/DecoderStateTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
// Copyright © 2026 Apple Inc. and the xcode-project-format project authors
//
// Licensed under Apache License v2.0 with Runtime Library Exception
// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception
//
//===----------------------------------------------------------------------===//

import Foundation
import Testing
import XcodeProjectFormat

private struct ParentValueProbe: XCJSON.Decodable {
init(with coder: XCJSON.Decoder) throws {
let container = try coder.openKeyedContainer()
let _: String = try container.decode("name")

#expect(coder.currentNodeType == .object)
_ = try coder.openKeyedContainer()
}
}

@Test func restoresParentValueAfterDecodingChild() throws {
let _: ParentValueProbe = try XCJSON.Decoder.decode(
data: Data(#"{"name":"App"}"#.utf8)
)
}