Skip to content

Type-store-issued handles for nominal types and indexes #1942

Open

Description

@shunichironomura

Warning

This content was written by an AI agent and must be verified by a human developer. After human verification, this alert may be removed.

Summary

Nominal types (constructors) and indexes are named in HIR and CheckedType by resolved names (ResolvedConstructorName, ResolvedIndexName via IndexTypeRef::Declared), and later stages look them up in the project type store. Those lookups can miss in principle and return internal errors.

Remaining sites

  • Nominal: generic_substitution.rs (constructor and field-semantics lookups), tir/typed/collect.rs, concrete_obligations.rs and dim_check/mod.rs (owner DagId → DAG).
  • SortedGenericArgs: CheckedType::Struct carries unvalidated generic arguments; it is used as an Eq/Hash type identity with about 15 construction sites.
  • Index axes (compile-side B2): expression_axes.rs, infer/hir/indexing.rs, recurrence.rs, prepare/model_schema.rs.

Why it was left out

HIR is finished per module before the project type store exists, so a store-issued handle needs a new completeness stage between HIR and the store. Nominals are shared across programs, so a DAG position cannot live on ResolvedNominal. Changing CheckedType::Struct changes a core type identity.

Proposed direction

Design the completeness stage first (a design doc), then introduce store-issued handles for constructors and indexes, then migrate the sites above. Expect this to be split into several PRs.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions