Skip to content

Drop read keywords for Symbol, VersionNumber, Regex, and sets - #112

Open
quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/construct-ignores-read-keywords
Open

quinnj-bot[bot] wants to merge 2 commits into
mainfrom
claude/construct-ignores-read-keywords

Conversation

@quinnj-bot

@quinnj-bot quinnj-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

Why

A JSON3 typed read passes its keywords (dateformat, allow_inf, parsequoted, ...) to StructTypes.construct. For Symbol, VersionNumber, Regex, and sets, construct falls back to T(args...; kw...), and those Base constructors take no keywords. So a read that passes any keyword fails as soon as it reaches one of these types:

JSON3.read("[1,2]", Set{Int}; allow_inf=true)        # MethodError: no method matching Set{Int64}(::Vector{Int64}; allow_inf::Bool)
JSON3.read("\"1.2.3\"", VersionNumber; dateformat=df) # MethodError
JSON3.read("\"a\\\"b\"", Symbol; allow_inf=true)      # MethodError (strings with an escape)

In practice this hits a struct with a Date field read with dateformat=... that also has a Set, Symbol, VersionNumber, or Regex field.

What changed

Scope

  • User types keep the default T(args...; kw...), so their constructors still receive the keywords.

Blast Radius

Calls without keywords give the same result as before. Calls with keywords that threw a MethodError now succeed.

Verification

  • New tests next to the existing UUID and Date keyword tests: all 6 throw a MethodError on main and pass on this branch. Pkg.test() passes on Julia 1.12.6, and JSON3's own test suite passes with this branch.
  • JSON3 1.14.4 main with this branch: JSON3.read(json, T; allow_inf=true) for Set{Int}, Set, BitSet, VersionNumber, Regex, and an escaped Symbol all read; without the branch all six throw.
  • Found by a differential typed-read harness for JSON3.

🤖 Generated with Claude Code

quinnj and others added 2 commits November 19, 2026 14:27
…nd sets

These fail on main: construct forwards the keywords to constructors that
take none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
construct fell back to T(args...; kw...) for these types, and their Base
constructors take no keywords, so a JSON3 typed read with dateformat or
allow_inf threw a MethodError when it reached one of them. construct now
calls their constructors without the keywords, as it does for UUID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.58%. Comparing base (916621a) to head (ec409c0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   78.38%   78.58%   +0.20%     
==========================================
  Files           2        2              
  Lines         421      425       +4     
==========================================
+ Hits          330      334       +4     
  Misses         91       91              

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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.

1 participant