Repository navigation
feat(ir)!: say what unions, literals and catch-alls admit - #1361
Open
OmarAlJarrah wants to merge 10 commits into
Open
OmarAlJarrah wants to merge 10 commits into
OmarAlJarrah wants to merge 10 commits into
Conversation
Four type-node facts a source states had no field, and two of them made the IR say two things at once. - Union gains Closed and InputOnly. A JSON Schema oneOf or anyOf is closed, while a Smithy union, a protobuf oneof and a GraphQL output union are open; a GraphQL @OneOf input object is input-only, as an input object is. Every union the OpenAPI compiler lowers is closed, and the new promotion target union.open opens one under a mapping that names a key. No default key names it. - Literal gains ValueType, read as an enum's is. 80 declared an integer and 80 declared a number were one Value, and a date const was a string, with the type or format kept under Unmodeled with an info report. Both now reach the field where the value fits them. - AdditionalProps.Value becomes optional. additionalProperties: false beside patternProperties typed the keys no pattern matches as the top type while Additional said none was allowed; such a catch-all now holds the patterns and no value. irverify reports a catch-all typing no key (ir/catch-all-empty) and a closed model's catch-all with a value (ir/catch-all-closed). - ValueKind gains inf, neginf and nan, so a protobuf default of inf is kept rather than dropped. BigVal stays a finite JSON number. BREAKING CHANGE: IRVersion moves to 0.28.0. A consumer pinned to 0.27.0 refuses the new document for its unknown members. AdditionalProps.Value is now a *TypeRef in Go, and a decoder reading it as required fails on a closed pattern object's catch-all.
7 tasks done
TestRegistryChecks_ListsEveryRegistryCheck holds the hand list to every function shaped like a registry check, and checkCatchAlls is one.
…at/ir-type-node-facts
A zero Union now writes closed and inputOnly, which the zero-shape contract lists. The comments on checkPrimKinds and the elected-lowering census test had grown past the 100-word cap.
…at/ir-type-node-facts # Conflicts: # docs/ir/version-history.md # ir/irversion_test.go
OmarAlJarrah
added a commit
that referenced
this pull request
Nov 2, 2026
This was referenced Nov 2, 2026
…at/ir-type-node-facts
The exhaustive linter holds every switch over ir.ValueKind to the whole enum. The literal type check in the census and the scalar renderer test now name inf, neginf and nan, and the census answers that no declared type holds a kind ir does not declare, which keeps the type keyword verbatim rather than claiming a home for it.
17 tasks done
…at/ir-type-node-facts # Conflicts: # docs/ir/version-history.md # ir/document.go # ir/irversion_test.go
The planted exhaustive finding is meant to name ir.ValueCtor alone; the switch now lists inf, neginf and nan, the kinds ir.ValueKind gained.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four facts a source states about a type node had no field in the IR. In two of them the IR said two things at once.
UniongainsClosed, asEnumhas it. A JSON SchemaoneOforanyOfadmits only what matches a listed branch, so every union the OpenAPI compiler lowers is closed. A Smithy union, a protobufoneofand a GraphQL output union are open: a consumer must represent a variant it does not know.docs/ir/unions.md#open-unionsstates the default for each format, and the planned lowerings follow it. The capability matrix gains anopen-unionsrow. The OpenAPI compiler gains a promotion target,union.open, read by presence asenum.openis. It has no default key, because no spelling has become common.testdata/conformance/openapi/matrix.mdtherefore records why no corpus spec can witness the row, and names the test that holds the promotion instead.UniongainsInputOnly, asModelhas it. A GraphQL@oneOfinput object is the source: an emitter projecting separate input and output types reads the flag instead of a format-named marker.ValueKindgainsinf,neginfandnan, each with no payload. A protobuf[default = inf]was a construct the IR could not hold, and every target with an IEEE float has a constant for each value. They are kinds rather than a flag onnumber, so a consumer switching onKindmeets them as kinds to handle, never as anumberwith an emptyNum.BigValstays a finite JSON number, andirverify's payload rules hold the new kinds with no rule of their own.LiteralgainsValueType, read asenumValueTypereads an enum's: the type and format the value fits, else the type, else the value's own kind.{type: integer, const: 80.0}isintegerand{type: number, const: 80}isnumber; they were oneValue. A dateconstisdate. Atypeorformatthe value fits no longer draws an info report or anUnmodeledentry. One it does not fit still draws both, and so does a type set naming several types.irverifyholds aValueTypeto the declared kinds (ir/unknown-prim-kindat the field).AdditionalProps.Valuebecomes*TypeRef.patternPropertiesbesideadditionalProperties: falseused to type every key no pattern matches as the top type, whileAdditionalsaid no such key was allowed. That catch-all now holds the patterns and no value.docs/ir/models.md#catch-allsstates the three shapes.irverifyreports the two that would say two things: a catch-all typing no key (ir/catch-all-empty), and a closed model's catch-all with a value (ir/catch-all-closed).On the golden spec (spec @319dc756), against this PR's base, the only change is the two new members on its 974 unions. The diagnostics are identical. The spec writes no
constand nopatternProperties: its 195 literals arenullor list members of an enum lowered as a union. That is the rule-3 ranking these issues carry.Closes #664
Closes #668
Closes #987
Closes #25
Breaking
IRVersionmoves to 0.31.0, the generation aftermain's 0.30.0 (#1327). The branch's earlier commits name 0.28.0 and 0.29.0, from before #1325, #1333 and #1327 landed; its merges ofmainrenumbered it. A consumer pinned to 0.30.0 refuses the document for its unknown members,closedandinputOnlyon every union andvalueTypeon a literal. One that decodesAdditionalProps.valueas required fails on a closed pattern object, where the member is absent. In Go,AdditionalProps.Valueis a*TypeRef. An open PR claiming the same version moves its own constant on if it merges after this one.Stack
Base: #1355, on #1354, #1351 and the emitter-design stack.
main(with #1229) is merged down the whole stack, so this diff is this PR's alone.Test plan
go teston the touched packages:ir,ir/irverify,ir/irfacts,compilers/openapi/internal/{schema,lowering,merge},compilers/openapi/e2e,internal/conformance,cmd/morphic,cmd/morphic-census. The goldens, the shape pin and the census were regenerated with-update.schema.TestLiteral_ValueTypeReadsTheTypeAndFormatItsValueFits(13 rows: fit, misfit, untyped, several types, composite, null);schema.TestObject_CatchAllBesideAnotherFactStaysModelgains the two pattern rows;irverify.TestCheckCatchAlls_ReportsACatchAllSayingTwoThings;irverify.TestVerify_ALiteralsUndeclaredValueTypeIsAViolation;lowering.TestPromoterUnionOpenness_OpensOnAMappedKey. Themapsconformance case gainsClosedPatternMap.integer,number,date, with no diagnostic. A misfittype: integer, const: xkeepstypeand reports it, andtype: objectbeside an objectconstkeeps nothing. The golden spec was compiled at the base and at this head, and the type and diagnostic differential is as stated above.mainor the base,skills_lintclean.maingained fix!: type the local time formats and keep time's offset #1325, the whole stack was merged forward and every touched package rerun:ir/...,compilers/...,cmd/...,engine/...,pass/...,internal/....