Skip to content

fix: prevent unique nil marker collisions - #1628

Open
fzlzjerry wants to merge 1 commit into
go-playground:masterfrom
fzlzjerry:fix/1627-distinct-unique-nil-sentinel
Open

fix: prevent unique nil marker collisions#1628
fzlzjerry wants to merge 1 commit into
go-playground:masterfrom
fzlzjerry:fix/1627-distinct-unique-nil-sentinel

Conversation

@fzlzjerry

Copy link
Copy Markdown

Fixes Or Enhances

Fixes #1627.

Use a function-local named type for the nil marker so it cannot compare equal to a legitimate anonymous struct{} value. The existing single-nil and duplicate-value semantics stay unchanged.

  • Cover slices, arrays, maps, pointer fields and nil parent pointers, with controls for duplicates and named structs.

  • The new regression fails on the five collision paths before the fix.

  • Full race/coverage suites pass on Go 1.25.14 and 1.26.8; golangci-lint v2.13.1 passes.

  • Allocation counts are unchanged across the 66 existing benchmarks and four targeted successful unique paths. Timing samples vary, so no throughput improvement is claimed.

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

@fzlzjerry
fzlzjerry requested a review from a team as a code owner September 9, 2026 05:44
Copilot AI lite review requested due to automatic review settings September 9, 2026 05:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[Bug]: unique confuses nil with an anonymous empty struct

2 participants