Skip to content

Derive inline-union allowlist from the spec; remove INLINE_UNIONS#97

Merged
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-derive-inline-unions
Jun 10, 2026
Merged

Derive inline-union allowlist from the spec; remove INLINE_UNIONS#97
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-derive-inline-unions

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

Replaces the hand-maintained INLINE_UNIONS allowlist with a rule derived purely from the spec: a union is inline iff it has no registered<PascalCase> sibling AND is referenced by at least one node attribute (recursively, through any wrapper type expression). The per-union stripSuffix is computed as the longest common PascalCase suffix shared by every flattened leaf's pascalCase(kind), trimmed back to start at an uppercase letter so we never strip mid-word. New helpers in unions.ts: isInlineUnion, getReferencedUnionNames, and getInlineUnionStripSuffix. getEmittableUnions now takes the full Spec (so it can see references from other categories) and applies the derived rule alongside the registered-twin check; unionPage.ts consults the new helpers instead of INLINE_UNIONS. The map and InlineUnionConfig are deleted from defaults.ts. Generated output is byte-identical (the derived rule produces the same stripSuffix ValueNode for both currently-emitted inline unions, constantPdaSeedValue and enumValuePayload).

lorisleiva commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jun 10, 2:13 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 10, 2:23 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 10, 2:23 PM UTC: @lorisleiva merged this pull request with Graphite.

@lorisleiva lorisleiva changed the base branch from loris/spec-gen-rename-rust-types to graphite-base/97 June 10, 2026 14:20
@lorisleiva lorisleiva changed the base branch from graphite-base/97 to main June 10, 2026 14:21
Replaces the hand-maintained `INLINE_UNIONS` allowlist with a rule derived purely from the spec: a union is inline iff it has no `registered<PascalCase>` sibling AND is referenced by at least one node attribute (recursively, through any wrapper type expression). The per-union `stripSuffix` is computed as the longest common PascalCase suffix shared by every flattened leaf's `pascalCase(kind)`, trimmed back to start at an uppercase letter so we never strip mid-word. New helpers in `unions.ts`: `isInlineUnion`, `getReferencedUnionNames`, and `getInlineUnionStripSuffix`. `getEmittableUnions` now takes the full `Spec` (so it can see references from other categories) and applies the derived rule alongside the registered-twin check; `unionPage.ts` consults the new helpers instead of `INLINE_UNIONS`. The map and `InlineUnionConfig` are deleted from `defaults.ts`. Generated output is byte-identical (the derived rule produces the same stripSuffix `ValueNode` for both currently-emitted inline unions, `constantPdaSeedValue` and `enumValuePayload`).
@lorisleiva lorisleiva force-pushed the loris/spec-gen-derive-inline-unions branch from ac27e64 to 7745d7d Compare June 10, 2026 14:22
@lorisleiva lorisleiva merged commit 2f97a9f into main Jun 10, 2026
4 checks passed
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.

1 participant