Skip to content

Campaign: migrate compiler id spaces to enforced-distinct types (NodeId, Symbol, TypeId, FileId) #666

Open

Description

@ehartford

The #660 class (a symbol id read as a node id) is representable because every compiler id space is a transparent i32. With has distinct types (§4.x, behav_distinct_compat.w) and the compiler now carries its first one: AstFileId (Ast.w, the per-node file column API). This campaign extends that to the load-bearing spaces.

Staged recipe (one space per stage, each gated by full build+fixpoint+test)

  1. FileId (~50 sites): unify Ast.AstFileId with compiler/foundation/Ids.FileId (currently a transparent alias — flip it to distinct), thread through Span.file, Lexer.file_id, Parser.file_id, Zcu source tables. Smallest space, proves the recipe end-to-end.
  2. TypeId (~hundreds): already aliased in Sema; flip to distinct, use the build-error list as the work queue (the flag-day 'red build is the instrument' protocol from D7).
  3. Symbol (~hundreds): parser/intern pool tier.
  4. NodeId (~thousands): last, biggest; after 1-3 the remaining mixing sites are precisely the interesting ones.

Rules

  • Each stage is a flag-day: flip the alias, let the compiler enumerate every mixing site, fix mechanically (explicit casts only at true boundaries: serialization, hashing, extra-pool packing).
  • Every explicit as i32 that survives a stage is a documented boundary, greppable forever.
  • Two-generation verification per stage; reseed between stages if the seed can no longer parse the tree.
  • Cross-pool id translation sites (codegen intern vs sema pool) become typed conversions instead of silent reuse.

Payoff: the #660/#663 class becomes a compile error; the pool-probing discriminators and their audits become redundant where adopted.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): still open. Only the pilot exists: type AstFileId = distinct i32 (src/Ast.w); NodeId, Symbol and TypeId are still transparent i32.

    post-release: a staged compiler-wide campaign.

  2. added this to the post-v0.16.0 milestone on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions