Skip to content

Fix Equal panic for null array elements - #227

Open
kom0055 wants to merge 1 commit into
evanphx:masterfrom
kom0055:codex/fix-equal-null-array
Open

kom0055 wants to merge 1 commit into
evanphx:masterfrom
kom0055:codex/fix-equal-null-array

Conversation

@kom0055

@kom0055 kom0055 commented Oct 14, 2026

Copy link
Copy Markdown

Equal panics for valid JSON such as [null] because array comparison passes nil child nodes to lazyNode.equal, which immediately dereferences the receiver.

Check both pointers before inspecting the node kind in the root/v4 and v5 implementations. Two null elements compare equal; a null and non-null element compare unequal. Other comparison behavior is unchanged.

Add regression tests for null elements in both directions, later array positions, nested arrays, reordered object keys, and differences following a null element. The regression fails with a nil pointer panic before the fix.

Fixes #226

Validation (Go 1.23.12, darwin/arm64):

  • GO111MODULE=off go test -vet=off (root/v4). Vet is disabled because the existing merge_test.go uses a non-constant Fatalf format string rejected by this toolchain's vet.
  • GOWORK=off go -C v5 test ./... (v5).

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.

Equal panics when comparing arrays containing null

1 participant