Skip to content

Add tests for Union{scalar, array} disambiguation#441

Closed
quinnj wants to merge 1 commit intomasterfrom
jq/union-array-scalar-tests
Closed

Add tests for Union{scalar, array} disambiguation#441
quinnj wants to merge 1 commit intomasterfrom
jq/union-array-scalar-tests

Conversation

@quinnj
Copy link
Copy Markdown
Member

@quinnj quinnj commented Mar 17, 2026

Summary

Test cases

  • Original issue: Tuple{Union{Float64, Nothing}, Union{Vector{Float64}, Float64}, Union{Vector{Float64}, Float64, Nothing}}
  • Direct struct fields: Union{Float64, Vector{Float64}}, Union{String, Vector{String}}, Union{Int, Vector{Int}}
  • With Nothing/Missing peeling: Union{Int, Vector{Int}, Nothing}, Union{Float64, Vector{Float64}, Missing}
  • Ambiguous case: Union{Vector{Int}, Set{Int}} (two arraylike types → throws)
  • Empty array materializes to the array type
  • Nested struct with Union field
  • Vector of structs where different elements use different Union branches

Dependencies

Requires JuliaServices/StructUtils.jl#44 to be merged and released.

🤖 Generated with Claude Code

Tests for StructUtils.jl#44 which fixes #436 — parsing JSON into types
with Union fields containing both arraylike and scalar members.

Covers: Union{T, Vector{T}}, Union{T, Vector{T}, Nothing/Missing},
ambiguous unions, empty arrays, nested structs, and the original
issue's Tuple with complex nested Union types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@quinnj
Copy link
Copy Markdown
Member Author

quinnj commented Mar 17, 2026

Closing in favor of having tests in StructUtils directly (JuliaServices/StructUtils.jl#44).

@quinnj quinnj closed this Mar 17, 2026
@quinnj quinnj deleted the jq/union-array-scalar-tests branch March 17, 2026 16:30
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.

MethodError when parsing JSON with nested Union types in Tuple field

1 participant