Skip to content

ir: canonical-naming grammar and primitive IDs are cross-compiler ABI living in one compiler #73

Description

@OmarAlJarrah

Problem

Two things every compiler must produce byte-identically are currently private code inside compilers/openapi:

  1. The canonical-naming grammar. canonicalWords (schema.go:1112-1149) defines what Naming.Canonical looks like (invariant 4's neutral word sequence). irverify only checks lowercase-idempotence, not word-splitting — so a TypeSpec compiler with its own splitter (HTTPServerhttpserver vs http_server) passes every oracle while breaking cross-format dedup/correlation and emitter casing consistency.
  2. Interned primitive IDs. t/prim/<kind> (ids.go:48) is referenced by golden files and will be emitted by every compiler — IR-level ABI defined nowhere in ir.

The RFC 6901 ptr/escape helpers and the diagf constructor are the same category of compiler-common machinery. Once a second compiler ships its own copies, the goldens of both lock in any divergence.

Proposed direction

Move canonicalWords into ir (e.g. ir.CanonicalWords) as the normative definition of Naming.Canonical — stdlib-only, no more "parsing" than NewDiagnostic's UTF-8 coercion — and tighten irverify to validate against it. Move PrimTypeID(PrimKind) into ir for the same reason. House the pointer/diag helpers in the shared compiler-support package proposed in #66. Size: S–M.

Acceptance

  • Naming.Canonical's grammar has exactly one definition, in Layer 0, and irverify checks conformance to it.
  • Primitive TypeIDs are constants/constructors in ir; the OpenAPI compiler and goldens are unchanged behaviorally.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions