Skip to content

fix(parse): forward type predicates to inner style#454

Merged
quinnj merged 1 commit into
masterfrom
claude/compassionate-lalande-adcedb
Apr 30, 2026
Merged

fix(parse): forward type predicates to inner style#454
quinnj merged 1 commit into
masterfrom
claude/compassionate-lalande-adcedb

Conversation

@quinnj
Copy link
Copy Markdown
Member

@quinnj quinnj commented Apr 30, 2026

Summary

  • Forward dictlike, arraylike, and nulllike from JSONReadStyle to its inner st.style so user-defined dispatches on a custom JSONStyle are honored during parsing.

Why

In v1.5.1, JSONReadStyle{O,T,S} was changed to wrap the user-provided style to carry null/dicttype/unknown_fields configuration through. But StructUtils.make() dispatches on the wrapping JSONReadStyle, so a user's dictlike(::CustomJSONStyle, ::Type{A}) = true never fired and make fell through to makestruct instead of makedict. This broke the deserialization pattern that worked in v1.5.0, where the user's style was passed through directly.

Forwarding only the type-routing predicates (dictlike/arraylike/nulllike) was chosen deliberately:

  • noarg/kwarg/structlike/fieldtags/fielddefaults are set via macros at the ::StructStyle level, which already match through JSONReadStyle.
  • Other JSONStyle-level defaults are inherited by any <: JSONStyle user style.
  • Forwarding the rest would create dispatch ambiguities with existing (::JSONStyle, ::Type{<:NamedTuple}) and macro-generated (::StructStyle, ::Type{<:T}) methods.

Closes #453

Test plan

  • Added regression test reproducing the exact issue example
  • Existing test suite passes (Pkg.test())

🤖 Generated with Claude Code

JSONReadStyle wraps the user-provided style for null/dicttype/unknown_fields config, but
StructUtils dispatches on the wrapping JSONReadStyle. As a result, methods like
dictlike(::CustomJSONStyle, ::Type{A}) defined on a user JSONStyle never fired during
parsing — make() fell through to makestruct instead of makedict.

Forward dictlike, arraylike, and nulllike from JSONReadStyle to its inner st.style so
user-defined dispatches on a custom JSONStyle reach the StructUtils make() router.

Closes #453

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.25%. Comparing base (95024e9) to head (86e3baa).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/parse.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
- Coverage   90.30%   90.25%   -0.06%     
==========================================
  Files           7        7              
  Lines        1392     1395       +3     
==========================================
+ Hits         1257     1259       +2     
- Misses        135      136       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj quinnj merged commit 8154d24 into master Apr 30, 2026
9 of 11 checks passed
@quinnj quinnj deleted the claude/compassionate-lalande-adcedb branch April 30, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing JSON ignores StructUtils methods for custom JSONStyle

1 participant