From ca671b9d0a4e1f794fd4c180c894d89c1b80402b Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Nov 2026 14:27:55 -0700 Subject: [PATCH 1/2] Test construct with read keywords for Symbol, VersionNumber, Regex, and sets These fail on main: construct forwards the keywords to constructors that take none. Co-Authored-By: Claude Opus 5.5 --- test/runtests.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index adf3c57..e4de31a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -212,6 +212,14 @@ x = "499beb72-22ea-11ea-3366-55749430b981" @test StructTypes.construct(UUID, pointer(x), 36) == UUID(x) @test StructTypes.construct(UUID, pointer(x), 36; dateformat=dateformat"mm-dd-yyyy") == UUID(x) @test StructTypes.construct(Date, "11-30-2019"; dateformat=dateformat"mm-dd-yyyy") == Date(2019, 11, 30) +# read keywords don't reach constructors that take none +df = dateformat"yyyy" +@test StructTypes.construct(Symbol, "hey"; dateformat=df) === :hey +@test StructTypes.construct(VersionNumber, "1.2.3"; dateformat=df) == v"1.2.3" +@test StructTypes.construct(Regex, "a.c"; dateformat=df) == r"a.c" +@test StructTypes.construct(Set{Int}, [1, 2, 2]; dateformat=df) == Set([1, 2]) +@test StructTypes.construct(Set, Any[1, "a"]; dateformat=df) == Set(Any[1, "a"]) +@test StructTypes.construct(BitSet, [3, 1]; dateformat=df) == BitSet([1, 3]) @test StructTypes.StructType(UInt8) == StructTypes.NumberType() @test StructTypes.StructType(Int8) == StructTypes.NumberType() From ec409c0a9e5fb10786fda6ba34d638fa1791fa98 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Nov 2026 14:27:55 -0700 Subject: [PATCH 2/2] Drop read keywords for Symbol, VersionNumber, Regex, and sets 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 --- src/StructTypes.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/StructTypes.jl b/src/StructTypes.jl index e1b7325..4fe335b 100644 --- a/src/StructTypes.jl +++ b/src/StructTypes.jl @@ -459,6 +459,9 @@ construct(::Type{Symbol}, ptr::Ptr{UInt8}, len::Int; kw...) = _symbol(ptr, len) construct(::Type{T}, str::String; dateformat::Dates.DateFormat=Dates.default_format(T), kw...) where {T <: Dates.TimeType} = T(str, dateformat) construct(::Type{UUID}, arg; kw...) = UUID(arg) +# these constructors take no keywords, so read keywords (like `dateformat`) are dropped +construct(::Type{T}, str::String; kw...) where {T <: Union{Symbol, VersionNumber, Regex}} = T(str) +construct(::Type{T}, x::AbstractVector; kw...) where {T <: AbstractSet} = T(x) """ StructTypes.StructType(::Type{T}) = StructTypes.NumberType()