Skip to content

conflicting-redeclaration keeps an IR TypeRef where ir-design 12 asks for the source construct #445

Description

@fuad-daoud

Found in review of #436 (Wahbeh-Mohammad).

keepLosingType writes the discarded ir.TypeRef as the Unmodeled value:

{"target":"t/prim/string","nullable":false}

ir/unmodeled.go and ir-design §12 define Value as "the source construct, verbatim". A TypeID is a compiler-minted registry ID, not source. This is the only site under compilers/ that marshals an IR struct into an Unmodeled payload.

The precedent cited in the code does not hold: annotation/constraints.go writes back a BigVal because a BigVal is the source literal text. A TypeID has no such property.

Two consequences:

  • irverify's reference walk (collectRefs) visits only string-kinded registry types. RawValue is a byte slice, so this reference can never be reported dangling. In allof-conflicting-type.golden.json, t/prim/string has zero live TypeRef referents; a future registry-pruning pass would orphan it and nothing would redden.
  • Where the losing branch carries residue (maxProperties and friends), preserveUnmergedBranch already keeps the whole branch node verbatim under openapi:allOf/<i>, so the loser would be preserved twice in two incompatible representations. The current fixture does not exhibit this because both branches declare only type: object plus properties.

Suggested fix: schema.go still holds the losing property's raw node (js in the props.All() loop) at the MergeProperty call. Pass it through and preserve those bytes. Alternatively, amend §12 and ir/unmodeled.go to permit an IR-value form and say why.

Deferred from #436 deliberately: it changes MergeProperty's signature and the golden, where #436's scope is the #424 fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions