Skip to content

Add noduplicates directive#438

Merged
klauspost merged 2 commits intotinylib:masterfrom
klauspost:noduplicates-directive
Apr 17, 2026
Merged

Add noduplicates directive#438
klauspost merged 2 commits intotinylib:masterfrom
klauspost:noduplicates-directive

Conversation

@klauspost
Copy link
Copy Markdown
Collaborator

This adds //msgp:noduplicates [TypeA TypeB ...] to generator files.

This will actively guards against duplicate keys when decoding/unmarshaling structs and maps.

Duplicate entries should never be generated as output. The only exception I can think of would be maps with shimming.

Generally duplicate keys is no issue unless there is some secondary checks that are inspecting streams (last entry on stream wins).

Shimmed keys - check keys after shim, before assignment. Catches both identical wire keys AND different wire keys that resolve to the same map key after shimming (e.g. "Foo" vs "foo" with a lowercasing shim).

AI Assisted (mostly tests)

This adds `//msgp:noduplicates [TypeA TypeB ...]` to generator files.

This will actively guards against duplicate keys when decoding/unmarshaling structs and maps.

Duplicate entries should never be generated as output and generally is no issue unless there is some secondary checks that are inspecting streams (last entry on stream wins).

Shimmed keys - late check after shim, before assignment. Catches both identical wire keys AND different wire keys that resolve to the same map key after shimming (e.g. "Foo" vs "foo" with a lowercasing shim).

AI Assisted (mostly tests)

This comment was marked as resolved.

@klauspost klauspost merged commit e856c5b into tinylib:master Apr 17, 2026
3 checks passed
@klauspost klauspost deleted the noduplicates-directive branch April 17, 2026 07:01
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.

3 participants