Skip to content

typecheck: special-case accretion in check_call and TypeChecker state; stdlib exists only as Rust tables #47

Description

@brianp

Found during a full documentation-validation sweep of the compiler (Aug 2026). Each item below is individually fine; the pattern is the concern — the typechecker is becoming the place where every feature lands as an inline special case, which makes it progressively harder to modify safely.

Symptoms

typecheck/src/check_call.rs (1,796 lines) intercepts special forms by name, inline:

  • is_acheck_call.rs:88
  • responds_tocheck_call.rs:91
  • contains predicate overload — check_call.rs:174
  • Set[T]() constructor parsed as Call(Index(...))check_call.rs:235
  • resolve_all / resolve_firstcheck_call.rs:295-296 (plus their function types re-declared at check_call.rs:1318-1330)
  • Mutex, Channel, MultiSend, MultiReceive constructors — check_call.rs:297-298
  • plus List[Nil] push-promotion and the DynamicReceiver method/bare-call fallback

typecheck/src/typechecker.rs (2,742 lines) carries accreted per-feature state flags:

  • is_maintypechecker.rs:30
  • const_namestypechecker.rs:35
  • task_bindingstypechecker.rs:40
  • boundary_crossedtypechecker.rs:47
  • nil_promotionstypechecker.rs:68

The standard library exists only as Rust tables inside the typechecker (register_builtins(), builtin_std_submodule_exports()) plus runtime intrinsics — there is no Aster-source stdlib layer. This also cuts against the stated goal that the stdlib not just be wrappers over host code.

Possible directions

  • A registry/mechanism for builtin constructors and intercepted calls instead of string matches inside check_call, so adding a builtin doesn't mean editing the dispatch spine.
  • Audit the per-feature state fields for consolidation into scoped context objects (some already moved to ScopeContext).
  • Longer-term: an Aster-source stdlib layer that typechecks like user code and lowers to the same intrinsics, so the Rust tables shrink to true primitives.

Documentation

Current behavior is documented (code-verified) in the docs site: docs/src/content/docs/internals/type-checker.mdx and internals/virtual-stdlib.mdx.

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

    mediumShould get done, not urgentstdlibStandard library modules and builtinstype-systemType checker, inference, generics, traits

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions