Skip to content

fix(compilers/openapi): map sized integer formats to primitives - #728

Open
fuad-daoud wants to merge 3 commits into
mainfrom
fix/sized-integer-primitives
Open

fuad-daoud wants to merge 3 commits into
mainfrom
fix/sized-integer-primitives

Conversation

@fuad-daoud

Copy link
Copy Markdown
Collaborator

Summary

formatTable mapped integer/int32, integer/int64, number/float, number/double, number/decimal and the string formats, and nothing else, so {type: integer, format: int8} lowered to an anonymous Scalar over t/prim/integer with Encoding.Name: int8 even though ir.PrimKind has PrimInt8.

This adds the seven entries naming a width of their base type — integer/int8, integer/int16, integer/uint8, integer/uint16, integer/uint32, integer/uint64, number/decimal128 — at their grouped positions, so those positions now resolve to the shared t/prim/<kind> primitive: no anonymous node, no Encoding, no diagnostic, and formatHome still reports the keyword homed through the primitive kind. formatTable's doc comment records the rule.

Deliberately unchanged: the literal float32/float64 spellings (float/double already map — the table maps OpenAPI format spellings, not TypeSpec type names), float16/uint128 (no such PrimKind), byte's own hoister, and the fallback that hoists an unlisted format as a Scalar over baseForType — including {type: string, format: int64} (#637).

The plan shipped with this fix is at docs/plans/636-sized-integer-primitives.md.

Test plan

  • go test ./compilers/openapi/internal/schema/ -run TestScalar -count=1 — green. The new TestScalar_NumericFormatsMapToPrimitive covers the seven new pairs, the int32/int64 and float/double/decimal controls, and two fallback boundary rows (number/float16, string/int64); a mapped row asserts the property target is ir.PrimTypeID(kind), the node is an *ir.Primitive of that kind, and no t/anon/... node exists at the property pointer.
  • Mutation probe: deleting the integer/uint32 entry reddens the uint32 subtest (t/anon/components/schemas/Holder/properties/p4 instead of t/prim/uint32); restoring it is green.
  • go test ./compilers/openapi -run TestConformance -count=1 — green, no golden changed.
  • make gate — exit 0 (fmt, vet, lint, nolint sweeps, build, coverage-count, coverage 100%, fuzz, bench-smoke).

@fuad-daoud fuad-daoud self-assigned this Sep 30, 2026
@fuad-daoud fuad-daoud changed the title fix(compilers/openapi): map sized integer formats to primitives (#636) fix(compilers/openapi): map sized integer formats to primitives Sep 30, 2026
Plans and agent working notes are not part of the repository; what a
reviewer needs is in the PR body, the commits and the linked issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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