Skip to content

Fix ambiguity from repeated embedded field types - #80

Open
bensynapse wants to merge 1 commit into
ajg:masterfrom
bensynapse:fix-ambiguous-embedded-fields
Open

bensynapse wants to merge 1 commit into
ajg:masterfrom
bensynapse:fix-ambiguous-embedded-fields

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

What & why

Closes #79.

Two wrappers embedding Common previously emitted its ambiguous X field using the first wrapper's value.
Track repeated embedded types at each depth so those conflicts are omitted, including through further embedding levels.
Counts stop at two, and each type enters the queue once per depth.

Compatibility: formerly emitted ambiguous fields disappear. Shallow fields, unique tagged winners and explicitly named parent paths retain their output.
The public API and error strings stay the same.

Both packages pass go test -v -cover ./... and go test -race ./... on Go 1.17.13 and 1.23.4.
Build, vet and formatting pass on both versions. Eleven new cases check all three encoder APIs.
Eighteen assertions fail against unchanged master and pass with this fix.

Checklist

  • gofmt, go vet, and go test ./... pass (root and ./multipart).
  • Behavior changes are pinned by a test.
  • No change to the public API, wire format, or error strings, or the PR says why.

Count repeated embedded types at each depth so their fields stay
ambiguous through further promotion. Visit each type once per depth
and cap counts at two to avoid expanding duplicate paths.
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.

Omit ambiguous fields reached through repeated embedded types

1 participant