Repository navigation
Construct the empty NamedTuple - #113
Open
quinnj-bot[bot] wants to merge 2 commits into
Open
quinnj-bot[bot] wants to merge 2 commits into
quinnj-bot[bot] wants to merge 2 commits into
Conversation
These fail on main with a MethodError: construct builds field-less types
with T(), and NamedTuple{(), Tuple{}} has no zero-argument constructor.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
construct(f, T) and construct(values, T) returned T() for types with no
fields, which throws for NamedTuple{(), Tuple{}}, so an empty NamedTuple
written by JSON3 could not be read back. They now call T(()) for
NamedTuple types and T() for the rest.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #113 +/- ##
==========================================
+ Coverage 78.38% 79.19% +0.81%
==========================================
Files 2 2
Lines 421 423 +2
==========================================
+ Hits 330 335 +5
+ Misses 91 88 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Why
constructbuilds a type with no fields by callingT(), and the emptyNamedTupletype has no zero-argument constructor:What changed
construct(f, T)andconstruct(values::Vector{Any}, T)build an emptyNamedTupletype withT(()). Other types with no fields still useT().Scope
NamedTupletypes among them.Blast Radius
The new branch is taken only for
NamedTuple{(), Tuple{}}, which always threw before.Verification
NamedTuplechecks throw onmain(theTuple{}check passes on both) and all 4 pass on this branch.Pkg.test()passes on Julia 1.12.6, and JSON3's own test suite passes with this branch.NamedTupleit wrote failed to read back.🤖 Generated with Claude Code