Skip to content

design: define initial HIR and monomorphization boundary #20

Description

@vycdev2

Summary

Define the first backend-neutral contract between Jett's checked program and jett_hir, including how concrete generic function instantiations are discovered, identified, deduplicated, and represented before MIR lowering.

Source documentation

Current state

Phase D is documented as not started, and the workspace has no jett_hir crate. The typechecker checks concrete generic function bodies on demand and interns generic struct instances, but its public CheckResult exposes only diagnostics, a span-to-type map, the type interner, and reflection metadata. The architecture describes HIR as consuming a TypedTree, but no such checked representation currently exists.

The tree-walking interpreter separately substitutes generic arguments while executing the source AST. Existing generic tests therefore validate parsing, checking, and interpretation, not a canonical monomorphization manifest or HIR lowering boundary.

Scope

This is a design and staging issue. It includes:

  • choosing the canonical checked-program representation consumed by HIR, whether that is a typed tree or a smaller checked AST plus compiler-owned maps;
  • defining stable function and concrete-instantiation identities, including discovery, deduplication, recursion, source spans, resolved parameter/return types, and invalid-call behavior;
  • defining the minimal initial HIR function/expression representation and which phase owns method resolution, desugaring, implicit views/copyability, and checked reflection metadata;
  • specifying how generic reflection specialization and trusted stdlib provenance cross the boundary without duplicating the policies tracked by design: define reflection predicate facts for generic specialization #6 and design: define module imports and trusted stdlib origins #3;
  • splitting implementation into independently testable stages with deterministic HIR snapshots or equivalent structural tests.

It does not include MIR/CFG lowering, definitive MIR ownership verification, optimization, LLVM/native code generation, a runtime library, interpreter bytecode, or changing current source-language semantics. It also does not require implementing the full HIR before the boundary is accepted.

Acceptance criteria

  • A concrete checked-program-to-HIR input contract is recorded and reconciles the documented TypedTree with the typechecker's actual outputs.
  • Canonical generic-instantiation discovery, identity, ordering, deduplication, recursion, and diagnostic behavior are specified.
  • The initial HIR data model and ownership of the Phase 7 transformations are defined without moving language policy into backend-specific code.
  • Reflection facts and trusted stdlib origin have explicit handoff points coordinated with design: define reflection predicate facts for generic specialization #6 and design: define module imports and trusted stdlib origins #3.
  • Staged implementation units and focused structural/snapshot tests are identified for multiple concrete instantiations, repeated calls, nested generic calls, constraints, methods, and rejected calls.
  • docs/design.md, docs/architecture.md, and docs/progress.md are updated to match the accepted boundary and status.
  • The originating planning docs remain in place and reflect the issue's final status.

Dependencies / open questions

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions