0%

Type checker: descriptor consumption + resolution rules

Goal

The type checker consumes the descriptor: registers imported type names, binds imported newtype/variant constructors in VALUE position only via an explicit import, and resolves variant PATTERNS type-directed against the scrutinee (never import-gated).

Implementation Sketch

register_imported_type consuming the descriptor (compiler/ori_types/src/check/imports.rs). Value-position variant resolution becomes import-scoped: registering an imported sum type supports annotations + pattern typing but a bare variant name resolves in expression position only when explicitly imported (do NOT make lookup_variant_def bare-resolve every registered type’s variants). Pattern position stays type-directed against the scrutinee (check_binding_pattern / try_resolve_unit_variant); a binding-shaped pattern name colliding with a scrutinee variant is a HARD ERROR, not a silent binding. Generic newtype constructors bind with their type parameters.

Spec References

Proposal Design (value-position import-scoped mechanism; variant-pattern type-directed rule + collision guard; generic newtypes); Clause 15 pattern resolution; Clause 18.3 import binding.

Work Items

  • register_imported_type consumes the descriptor; value-position variant resolution is import-scoped (variant names enter the value namespace only via explicit import, never as a side effect of registering the type).
  • Variant-pattern resolution stays type-directed against the scrutinee; hard error on a binding-shaped pattern name colliding with a scrutinee variant; generic-newtype constructor binds with its type parameters.