Repository navigation
Conversation
The decoder's decode(_:pathComponent:) method was incorrectly saving the incoming value parameter instead of the decoder's currentValue before decoding a child. This caused the parent context to be lost after child decoding completed. Changed to save and restore currentValue, ensuring the decoder's state is properly maintained across nested decode operations. Fixes apple#3
hippi345
marked this pull request as ready for review
October 15, 2026 15:37
hippi345
requested review from
deccylol,
jakepetroules,
jonathanjhess,
owenv and
rconnell9
as code owners
October 15, 2026 15:37
11 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix decoder state restoration after decoding child
Type of change
xcprojformatter(CLI) changeSummary
Fixes a bug in
XCJSON.Decoder.decode(_:pathComponent:)where the decoder incorrectly saved the incomingvalueparameter instead of its owncurrentValuebefore decoding a child element. This caused the decoder to lose track of the parent context after child decoding completed.Related issue
Fixes #3
Changes
Decoder.swiftline 33 fromlet oldCurrentValue = valuetolet oldCurrentValue = currentValueDecoderStateTests.swiftwith a regression test that verifies the decoder properly restores parent state after decoding a childTesting
swift test)Sources/Tests/DecoderStateTests.swiftswift test --filter restoresParentValueAfterDecodingChildbefore the fix - it failed with "Expected an instance of dictionary but an instance string was specified"Decoder.swiftswift test) - all 32 tests passedChecklist
Additional notes
This contribution was prepared with AI assistance (Claude via Cursor Cloud Agent). The fix itself is a single-line change that corrects the variable being captured in the defer block. The test case was provided in the original issue report and validates that after decoding a child value, the decoder's
currentNodeTyperemains.objectand the parent's keyed container can be reopened.