Skip to content

Drop flat structs for complex union types. - #376

Merged
sudomateo merged 1 commit into
mainfrom
jmcarp/drop-flat-struct
Feb 16, 2026
Merged

Drop flat structs for complex union types.#376
sudomateo merged 1 commit into
mainfrom
jmcarp/drop-flat-struct

Conversation

@jmcarp

@jmcarp jmcarp commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Earlier, we switched from any to interfaces with variant structs to represent tagged unions with a single value field. We left tagged unions with multiple value fields as flat structs at the time. This patch finishes the migration to interfaces for all tagged unions.

Downstream PRs:

@jmcarp
jmcarp force-pushed the jmcarp/drop-flat-struct branch 3 times, most recently from 0b723bf to ff67b95 Compare February 12, 2026 16:58
@jmcarp
jmcarp marked this pull request as ready for review February 13, 2026 16:19
@jmcarp
jmcarp requested a review from a team as a code owner February 13, 2026 16:19

@lgfa29 lgfa29 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I focused mostly in the DESIGN.md and generated output, but changes LGTM

@sudomateo sudomateo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The design and generation logic look good to me!

Drop the flat struct pattern for representing tagged unions with multiple value
types, and instead use interfaces with variant types.

Note that we also fix pre-existing bugs related to marshalling and
unmarshalling interface wrapper types. We now correctly serialize nil
interfaces to `null`, rather than `{"type": ""}`, and correspondingly unmarshal
null oneOf fields to `nil`.
@sudomateo
sudomateo force-pushed the jmcarp/drop-flat-struct branch from ff67b95 to a9e7de7 Compare February 16, 2026 17:43
@sudomateo
sudomateo merged commit 30fa749 into main Feb 16, 2026
1 check passed
@sudomateo
sudomateo deleted the jmcarp/drop-flat-struct branch February 16, 2026 17:44
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